chore: clean up typings
This commit is contained in:
@@ -1,12 +1,3 @@
|
||||
import { Lang } from "@/constants/languages"
|
||||
|
||||
import {
|
||||
AccountPageContentItem,
|
||||
ContentEntries,
|
||||
DynamicContentComponents,
|
||||
} from "@/types/requests/myPages/accountpage"
|
||||
import { User } from "@/types/user"
|
||||
|
||||
import CurrentBenefitsBlock from "@/components/MyPages/Blocks/Benefits/CurrentLevel"
|
||||
import JsonToHtml from "@/components/JsonToHtml"
|
||||
import NextLevelBenefitsBlock from "@/components/MyPages/Blocks/Benefits/NextLevel"
|
||||
@@ -15,62 +6,62 @@ import Shortcuts from "@/components/MyPages/Blocks/Shortcuts"
|
||||
import UpcomingStays from "@/components/MyPages/Blocks/Stays/Upcoming"
|
||||
import SoonestStays from "@/components/MyPages/Blocks/Stays/Soonest"
|
||||
import { renderOptions } from "@/components/JsonToHtml/renderOptions"
|
||||
import { AccountPageContentProps } from "@/types/components/myPages/myPage/accountPage"
|
||||
import PreviousStays from "../Blocks/Stays/Previous"
|
||||
|
||||
function DynamicComponent({ user, lang, content }: AccountPageContentProps) {
|
||||
const link = content.link.linkConnection.edges.length
|
||||
? {
|
||||
href: content.link.linkConnection.edges[0].node.url,
|
||||
text: content.link.link_text,
|
||||
}
|
||||
: null
|
||||
import {
|
||||
ContentEntries,
|
||||
DynamicContentComponents,
|
||||
} from "@/types/requests/myPages/accountpage"
|
||||
import {
|
||||
AccountPageContentProps,
|
||||
ContentProps,
|
||||
} from "@/types/components/myPages/myPage/accountPage"
|
||||
|
||||
const componentProps = {
|
||||
lang,
|
||||
title: content.title,
|
||||
// TODO: rename preamble to subtitle in Contentstack
|
||||
subtitle: content.preamble,
|
||||
...link,
|
||||
}
|
||||
|
||||
switch (content.component) {
|
||||
function DynamicComponent({ user, component, props }: AccountPageContentProps) {
|
||||
switch (component) {
|
||||
case DynamicContentComponents.membership_overview:
|
||||
return <Overview user={user} title={content.title} />
|
||||
return <Overview user={user} title={props.title} />
|
||||
case DynamicContentComponents.previous_stays:
|
||||
return <PreviousStays {...componentProps} />
|
||||
return <PreviousStays {...props} />
|
||||
case DynamicContentComponents.soonest_stays:
|
||||
return <SoonestStays {...componentProps} />
|
||||
return <SoonestStays {...props} />
|
||||
case DynamicContentComponents.upcoming_stays:
|
||||
return <UpcomingStays {...componentProps} />
|
||||
return <UpcomingStays {...props} />
|
||||
case DynamicContentComponents.current_benefits:
|
||||
return <CurrentBenefitsBlock {...componentProps} />
|
||||
return <CurrentBenefitsBlock {...props} />
|
||||
case DynamicContentComponents.next_benefits:
|
||||
return <NextLevelBenefitsBlock {...componentProps} />
|
||||
return <NextLevelBenefitsBlock {...props} />
|
||||
default:
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export default function Content({
|
||||
user,
|
||||
lang,
|
||||
content,
|
||||
}: {
|
||||
user: User
|
||||
lang: Lang
|
||||
content: AccountPageContentItem[]
|
||||
}) {
|
||||
export default function Content({ user, lang, content }: ContentProps) {
|
||||
return (
|
||||
<>
|
||||
{content.map((item) => {
|
||||
switch (item.__typename) {
|
||||
case ContentEntries.AccountPageContentDynamicContent:
|
||||
const link = item.dynamic_content.link.linkConnection.edges.length
|
||||
? {
|
||||
href: item.dynamic_content.link.linkConnection.edges[0].node
|
||||
.url,
|
||||
text: item.dynamic_content.link.link_text,
|
||||
}
|
||||
: null
|
||||
|
||||
const componentProps = {
|
||||
lang,
|
||||
title: item.dynamic_content.title,
|
||||
// TODO: rename preamble to subtitle in Contentstack
|
||||
subtitle: item.dynamic_content.preamble,
|
||||
...link,
|
||||
}
|
||||
return (
|
||||
<DynamicComponent
|
||||
component={item.dynamic_content.component}
|
||||
user={user}
|
||||
lang={lang}
|
||||
content={item.dynamic_content}
|
||||
props={componentProps}
|
||||
/>
|
||||
)
|
||||
case ContentEntries.AccountPageContentShortcuts:
|
||||
|
||||
Reference in New Issue
Block a user