53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import JsonToHtml from "@/components/JsonToHtml"
|
|
import SidebarMyPages from "@/components/MyPages/Sidebar"
|
|
|
|
import JoinLoyaltyContact from "./JoinLoyalty"
|
|
|
|
import styles from "./sidebar.module.css"
|
|
|
|
import {
|
|
LoyaltySidebarDynamicComponentEnum,
|
|
SidebarTypenameEnum,
|
|
} from "@/types/components/loyalty/enums"
|
|
import { SidebarProps } from "@/types/components/loyalty/sidebar"
|
|
|
|
export default function SidebarLoyalty({ blocks }: SidebarProps) {
|
|
return (
|
|
<aside className={styles.aside}>
|
|
{blocks.map((block, idx) => {
|
|
switch (block.__typename) {
|
|
case SidebarTypenameEnum.LoyaltyPageSidebarContent:
|
|
return (
|
|
<section
|
|
className={styles.content}
|
|
key={`${block.__typename}-${idx}`}
|
|
>
|
|
<JsonToHtml
|
|
embeds={block.content.content.embedded_itemsConnection.edges}
|
|
nodes={block.content.content.json.children}
|
|
/>
|
|
</section>
|
|
)
|
|
case SidebarTypenameEnum.LoyaltyPageSidebarJoinLoyaltyContact:
|
|
return (
|
|
<JoinLoyaltyContact
|
|
block={block.join_loyalty_contact}
|
|
key={`${block.__typename}-${idx}`}
|
|
/>
|
|
)
|
|
case SidebarTypenameEnum.LoyaltyPageSidebarDynamicContent:
|
|
switch (block.dynamic_content.component) {
|
|
case LoyaltySidebarDynamicComponentEnum.my_pages_navigation:
|
|
return <SidebarMyPages key={`${block.__typename}-${idx}`} />
|
|
default:
|
|
return null
|
|
}
|
|
|
|
default:
|
|
return null
|
|
}
|
|
})}
|
|
</aside>
|
|
)
|
|
}
|