35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import List from "./List"
|
|
import Puffs from "./Puffs"
|
|
import Text from "./Text"
|
|
|
|
import { BlocksTypenameEnum } from "@/types/requests/utils/typename"
|
|
|
|
import styles from "./blocks.module.css"
|
|
import type { BlocksProps } from "@/types/components/current/blocks"
|
|
|
|
export default function Blocks({ blocks }: BlocksProps) {
|
|
if (!blocks?.length) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<section className={styles.wrapper}>
|
|
{blocks.map((block) => {
|
|
const type = block.__typename
|
|
switch (type) {
|
|
case BlocksTypenameEnum.CurrentBlocksPageBlocksList:
|
|
return <List key={block.__typename} {...block} />
|
|
case BlocksTypenameEnum.CurrentBlocksPageBlocksPuffs:
|
|
return <Puffs key={block.__typename} {...block} />
|
|
case BlocksTypenameEnum.CurrentBlocksPageBlocksText:
|
|
return <Text key={block.__typename} {...block} />
|
|
default:
|
|
console.log(`Unknown type: (${type})`)
|
|
return null
|
|
}
|
|
})}
|
|
<div id="mainarea_personalized"></div>
|
|
</section>
|
|
)
|
|
}
|