fix: move typings
This commit is contained in:
@@ -15,7 +15,6 @@ export default async function MyStays({ params }: PageArgs<LangParams>) {
|
||||
subtitle={
|
||||
"Excited about your next trip? So are we. Below are your upcoming stays with us, complete with all the details you need to make each visit perfect. Can't wait to welcome you back, friend!"
|
||||
}
|
||||
link={null}
|
||||
/>
|
||||
<PreviousStays
|
||||
lang={params.lang}
|
||||
@@ -23,7 +22,6 @@ export default async function MyStays({ params }: PageArgs<LangParams>) {
|
||||
subtitle={
|
||||
"Revisit your stays and rekindle those our moments together, with ease."
|
||||
}
|
||||
link={null}
|
||||
/>
|
||||
</MaxWidth>
|
||||
)
|
||||
|
||||
@@ -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(
|
||||
{},
|
||||
|
||||
16
types/components/myPages/myPage/accountPage.ts
Normal file
16
types/components/myPages/myPage/accountPage.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Lang } from "@/constants/languages"
|
||||
import { DynamicContent } from "@/types/requests/myPages/accountpage"
|
||||
import { User } from "@/types/user"
|
||||
|
||||
export type AccountPageContentProps = {
|
||||
content: DynamicContent
|
||||
lang: Lang
|
||||
user: User
|
||||
}
|
||||
|
||||
export type AccountPageComponentProps = {
|
||||
lang: Lang
|
||||
title: string
|
||||
subtitle?: string
|
||||
link?: { href: string; text: string }
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import { Shortcut } from "@/types/requests/myPages/accountpage"
|
||||
import { PageLink } from "@/types/requests/utils/pageLink"
|
||||
import { ReactNode } from "react"
|
||||
|
||||
export type ShortcutsProps = {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export type HeaderProps = {
|
||||
title: string
|
||||
subtitle?: string
|
||||
link: { href: string; text: string } | null
|
||||
link?: { href: string; text: string }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user