feat: create blocks component for loyalty
This commit is contained in:
26
components/Loyalty/Blocks/index.tsx
Normal file
26
components/Loyalty/Blocks/index.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import JsonToHtml from "@/components/JsonToHtml"
|
||||
|
||||
import {
|
||||
Blocks as BlocksType,
|
||||
LoyaltyBlocksTypenameEnum,
|
||||
} from "@/types/requests/loyaltyPage"
|
||||
|
||||
export function Blocks({ blocks }: { blocks: BlocksType[] }) {
|
||||
return blocks.map((block) => {
|
||||
switch (block.__typename) {
|
||||
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksCardGrid:
|
||||
return <p>Cards</p>
|
||||
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksContent:
|
||||
return (
|
||||
<JsonToHtml
|
||||
nodes={block.content.json.children}
|
||||
embeds={block.content.embedded_itemsConnection.edges}
|
||||
/>
|
||||
)
|
||||
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksDynamicContent:
|
||||
return <p>Dynamic</p>
|
||||
default:
|
||||
return null
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user