import JsonToHtml from "@/components/JsonToHtml"
import Overview from "@/components/MyPages/Blocks/Overview"
import Shortcuts from "@/components/MyPages/Blocks/Shortcuts"
import { getLang } from "@/i18n/serverContext"
import { removeMultipleSlashes } from "@/utils/url"
import { modWebviewLink } from "@/utils/webviews"
import CurrentBenefitsBlock from "../../Blocks/Benefits/CurrentLevel"
import NextLevelBenefitsBlock from "../../Blocks/Benefits/NextLevel"
import EarnAndBurn from "../../Blocks/Points/EarnAndBurn"
import PointsOverview from "../../Blocks/Points/Overview"
import {
AccountPageContentProps,
ContentProps,
} from "@/types/components/myPages/myPage/accountPage"
import {
ContentEntries,
DynamicContentComponents,
} from "@/types/components/myPages/myPage/enums"
function DynamicComponent({ component, props }: AccountPageContentProps) {
switch (component) {
case DynamicContentComponents.membership_overview:
return
case DynamicContentComponents.points_overview:
return
case DynamicContentComponents.current_benefits:
return
case DynamicContentComponents.next_benefits:
return
case DynamicContentComponents.expiring_points:
// TODO: Add once available
// return
return null
case DynamicContentComponents.earn_and_burn:
return
default:
return null
}
}
export default function Content({ content }: ContentProps) {
return (
<>
{content.map((item, idx) => {
switch (item.__typename) {
case ContentEntries.AccountPageContentDynamicContent:
const link = item.dynamic_content.link.linkConnection.edges.length
? {
href:
item.dynamic_content.link.linkConnection.edges[0].node
.original_url ||
modWebviewLink(
removeMultipleSlashes(
`/${item.dynamic_content.link.linkConnection.edges[0].node.system.locale}/${item.dynamic_content.link.linkConnection.edges[0].node.url}`
),
item.dynamic_content.link.linkConnection.edges[0].node
.system.locale
),
text: item.dynamic_content.link.link_text,
}
: null
const componentProps = {
title: item.dynamic_content.title,
// TODO: rename preamble to subtitle in Contentstack?
subtitle: item.dynamic_content.preamble,
...(link && { link }),
}
return (
)
case ContentEntries.AccountPageContentShortcuts:
const shortcuts = item.shortcuts.shortcuts.map((shortcut) => {
return {
...shortcut,
url: modWebviewLink(shortcut.url, getLang()),
}
})
return (
)
case ContentEntries.AccountPageContentTextContent:
return (
)
default:
return null
}
})}
>
)
}