50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import JsonToHtml from "@/components/JsonToHtml"
|
|
|
|
import JoinLoyaltyContact from "./JoinLoyalty"
|
|
import MyPagesNavigation from "./MyPagesNavigation"
|
|
|
|
import styles from "./sidebar.module.css"
|
|
|
|
import type { SidebarProps } from "@/types/components/sidebar"
|
|
import { DynamicContentEnum } from "@/types/enums/dynamicContent"
|
|
import { SidebarEnums } from "@/types/enums/sidebar"
|
|
|
|
export default function Sidebar({ blocks }: SidebarProps) {
|
|
return (
|
|
<aside className={styles.aside}>
|
|
{blocks.map((block, idx) => {
|
|
switch (block.typename) {
|
|
case SidebarEnums.blocks.Content:
|
|
return (
|
|
<section
|
|
className={styles.content}
|
|
key={`${block.typename}-${idx}`}
|
|
>
|
|
<JsonToHtml
|
|
embeds={block.content.embedded_itemsConnection.edges}
|
|
nodes={block.content.json.children}
|
|
/>
|
|
</section>
|
|
)
|
|
case SidebarEnums.blocks.DynamicContent:
|
|
switch (block.dynamic_content.component) {
|
|
case DynamicContentEnum.Sidebar.components.my_pages_navigation:
|
|
return <MyPagesNavigation key={`${block.typename}-${idx}`} />
|
|
default:
|
|
return null
|
|
}
|
|
case SidebarEnums.blocks.JoinLoyaltyContact:
|
|
return (
|
|
<JoinLoyaltyContact
|
|
block={block.join_loyalty_contact}
|
|
key={`${block.typename}-${idx}`}
|
|
/>
|
|
)
|
|
default:
|
|
return null
|
|
}
|
|
})}
|
|
</aside>
|
|
)
|
|
}
|