fix: move typings

This commit is contained in:
Arvid Norlin
2024-04-22 14:04:20 +02:00
parent dff21b33cd
commit 7b92be973c
10 changed files with 43 additions and 56 deletions

View File

@@ -3,7 +3,6 @@ import { Lang } from "@/constants/languages"
import {
AccountPageContentItem,
ContentEntries,
DynamicContent,
DynamicContentComponents,
} from "@/types/requests/myPages/accountpage"
import { User } from "@/types/user"
@@ -16,36 +15,34 @@ 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
function DynamicComponent({
user,
lang,
content,
}: {
content: DynamicContent
lang: Lang
user: User
}) {
const componentProps = {
lang,
title: content.title,
// TODO: rename preamble to subtitle in Contentstack
subtitle: content.preamble,
link: content.link.linkConnection.edges.length
? {
href: content.link.linkConnection.edges[0].node.url,
text: content.link.link_text,
}
: null,
...link,
}
switch (content.component) {
case DynamicContentComponents.membership_overview:
return <Overview user={user} />
case DynamicContentComponents.previous_stays:
return null
return <PreviousStays {...componentProps} />
case DynamicContentComponents.soonest_stays:
return <SoonestStays lang={lang} {...componentProps} />
return <SoonestStays {...componentProps} />
case DynamicContentComponents.upcoming_stays:
return <UpcomingStays lang={lang} {...componentProps} />
return <UpcomingStays {...componentProps} />
case DynamicContentComponents.current_benefits:
return <CurrentBenefitsBlock {...componentProps} />
case DynamicContentComponents.next_benefits: