feat: graphql client with fetches for initial pages

This commit is contained in:
Simon Emanuelsson
2024-02-01 16:19:16 +01:00
parent a91781137a
commit 5e974aa3da
56 changed files with 2580 additions and 1512 deletions
+34
View File
@@ -0,0 +1,34 @@
import List from "./Blocks/List"
import Preamble from "./Blocks/Preamble"
import Puffs from "./Blocks/Puffs"
import Text from "./Blocks/Text"
import { BlocksTypenameEnum } from "@/types/requests/utils/typename"
import type { BlocksProps } from "@/types/components/current/blocks"
export default function Blocks({ blocks }: BlocksProps) {
if (!blocks?.length) {
return null
}
return (
<>
{blocks.map(block => {
const type = block.__typename
switch (type) {
case BlocksTypenameEnum.CurrentBlocksPageBlocksList:
return <List key={block.__typename} {...block} />
case BlocksTypenameEnum.CurrentBlocksPageBlocksPreamble:
return <Preamble 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
}
})}
</>
)
}