fix: move typings
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -11,12 +11,13 @@ export type CurrentLevelProps = {
|
||||
subtitle?: string
|
||||
link: { text: string; href: string } | null
|
||||
}
|
||||
import { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage"
|
||||
|
||||
export default async function CurrentBenefitsBlock({
|
||||
title,
|
||||
subtitle,
|
||||
link,
|
||||
}: CurrentLevelProps) {
|
||||
}: AccountPageComponentProps) {
|
||||
const benefits = await serverClient().user.benefits.current()
|
||||
|
||||
return (
|
||||
|
||||
@@ -7,18 +7,13 @@ import Button from "@/components/TempDesignSystem/Button"
|
||||
import Title from "@/components/Title"
|
||||
|
||||
import styles from "./next.module.css"
|
||||
|
||||
export type NextLevelProps = {
|
||||
title: string
|
||||
subtitle?: string
|
||||
link: { href: string; text: string } | null
|
||||
}
|
||||
import { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage"
|
||||
|
||||
export default async function NextLevelBenefitsBlock({
|
||||
title,
|
||||
subtitle,
|
||||
link,
|
||||
}: NextLevelProps) {
|
||||
}: AccountPageComponentProps) {
|
||||
const { nextLevel, perks } = await serverClient().user.benefits.nextLevel()
|
||||
|
||||
return (
|
||||
|
||||
@@ -11,21 +11,15 @@ import ShowMoreButton from "../ShowMoreButton"
|
||||
import StayList from "../StayList"
|
||||
import EmptyPreviousStaysBlock from "./EmptyPreviousStays"
|
||||
|
||||
import { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage"
|
||||
import type { Page } from "@/types/components/myPages/myStays/page"
|
||||
|
||||
type PreviousStaysProps = {
|
||||
lang: Lang
|
||||
title: string
|
||||
subtitle?: string
|
||||
link: { href: string; text: string } | null
|
||||
}
|
||||
|
||||
export default function PreviousStays({
|
||||
lang,
|
||||
title,
|
||||
subtitle,
|
||||
link,
|
||||
}: PreviousStaysProps) {
|
||||
}: AccountPageComponentProps) {
|
||||
const { data, isFetching, fetchNextPage, hasNextPage } =
|
||||
trpc.user.stays.previous.useInfiniteQuery(
|
||||
{},
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Lang } from "@/constants/languages"
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import Header from "../Header"
|
||||
@@ -7,19 +6,14 @@ import EmptyUpcomingStaysBlock from "./EmptyUpcomingStays"
|
||||
|
||||
import styles from "./soonest.module.css"
|
||||
|
||||
type UpcomingStaysProps = {
|
||||
lang: Lang
|
||||
title: string
|
||||
subtitle?: string
|
||||
link: { text: string; href: string } | null
|
||||
}
|
||||
import { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage"
|
||||
|
||||
export default async function UpcomingStays({
|
||||
lang,
|
||||
title,
|
||||
subtitle,
|
||||
link,
|
||||
}: UpcomingStaysProps) {
|
||||
}: AccountPageComponentProps) {
|
||||
const stays = await serverClient().user.stays.soonestUpcoming()
|
||||
|
||||
return (
|
||||
|
||||
@@ -11,21 +11,15 @@ import ShowMoreButton from "../ShowMoreButton"
|
||||
import StayList from "../StayList"
|
||||
import EmptyUpcomingStaysBlock from "./EmptyUpcomingStays"
|
||||
|
||||
import { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage"
|
||||
import type { Page } from "@/types/components/myPages/myStays/page"
|
||||
|
||||
type UpcomingStaysProps = {
|
||||
lang: Lang
|
||||
title: string
|
||||
subtitle?: string
|
||||
link: { text: string; href: string } | null
|
||||
}
|
||||
|
||||
export default function UpcomingStays({
|
||||
lang,
|
||||
title,
|
||||
subtitle,
|
||||
link,
|
||||
}: UpcomingStaysProps) {
|
||||
}: AccountPageComponentProps) {
|
||||
const { data, hasNextPage, isFetching, fetchNextPage } =
|
||||
trpc.user.stays.upcoming.useInfiniteQuery(
|
||||
{},
|
||||
|
||||
Reference in New Issue
Block a user