import Puffs from "./Asides/Puffs"

import { AsideTypenameEnum } from "@/types/requests/utils/typename"
import type { AsideProps } from "@/types/components/current/aside"

export default function Aside({ blocks }: AsideProps) {
  if (!blocks?.length) {
    return null
  }

  return (
    <aside>
      {blocks.map((block, idx) => {
        const type = block.__typename
        switch (type) {
          case AsideTypenameEnum.CurrentBlocksPageAsideContact:
            return null
          case AsideTypenameEnum.CurrentBlocksPageAsidePuff:
            return <Puffs key={`block-${idx}`} puffs={block.puff.puffConnection.edges} />
          default:
            return null
        }
      })}
    </aside>
  )
}
