fix: move typings
This commit is contained in:
@@ -15,7 +15,6 @@ export default async function MyStays({ params }: PageArgs<LangParams>) {
|
|||||||
subtitle={
|
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!"
|
"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
|
<PreviousStays
|
||||||
lang={params.lang}
|
lang={params.lang}
|
||||||
@@ -23,7 +22,6 @@ export default async function MyStays({ params }: PageArgs<LangParams>) {
|
|||||||
subtitle={
|
subtitle={
|
||||||
"Revisit your stays and rekindle those our moments together, with ease."
|
"Revisit your stays and rekindle those our moments together, with ease."
|
||||||
}
|
}
|
||||||
link={null}
|
|
||||||
/>
|
/>
|
||||||
</MaxWidth>
|
</MaxWidth>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { Lang } from "@/constants/languages"
|
|||||||
import {
|
import {
|
||||||
AccountPageContentItem,
|
AccountPageContentItem,
|
||||||
ContentEntries,
|
ContentEntries,
|
||||||
DynamicContent,
|
|
||||||
DynamicContentComponents,
|
DynamicContentComponents,
|
||||||
} from "@/types/requests/myPages/accountpage"
|
} from "@/types/requests/myPages/accountpage"
|
||||||
import { User } from "@/types/user"
|
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 UpcomingStays from "@/components/MyPages/Blocks/Stays/Upcoming"
|
||||||
import SoonestStays from "@/components/MyPages/Blocks/Stays/Soonest"
|
import SoonestStays from "@/components/MyPages/Blocks/Stays/Soonest"
|
||||||
import { renderOptions } from "@/components/JsonToHtml/renderOptions"
|
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 = {
|
const componentProps = {
|
||||||
|
lang,
|
||||||
title: content.title,
|
title: content.title,
|
||||||
// TODO: rename preamble to subtitle in Contentstack
|
// TODO: rename preamble to subtitle in Contentstack
|
||||||
subtitle: content.preamble,
|
subtitle: content.preamble,
|
||||||
link: content.link.linkConnection.edges.length
|
...link,
|
||||||
? {
|
|
||||||
href: content.link.linkConnection.edges[0].node.url,
|
|
||||||
text: content.link.link_text,
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (content.component) {
|
switch (content.component) {
|
||||||
case DynamicContentComponents.membership_overview:
|
case DynamicContentComponents.membership_overview:
|
||||||
return <Overview user={user} />
|
return <Overview user={user} />
|
||||||
case DynamicContentComponents.previous_stays:
|
case DynamicContentComponents.previous_stays:
|
||||||
return null
|
return <PreviousStays {...componentProps} />
|
||||||
case DynamicContentComponents.soonest_stays:
|
case DynamicContentComponents.soonest_stays:
|
||||||
return <SoonestStays lang={lang} {...componentProps} />
|
return <SoonestStays {...componentProps} />
|
||||||
case DynamicContentComponents.upcoming_stays:
|
case DynamicContentComponents.upcoming_stays:
|
||||||
return <UpcomingStays lang={lang} {...componentProps} />
|
return <UpcomingStays {...componentProps} />
|
||||||
case DynamicContentComponents.current_benefits:
|
case DynamicContentComponents.current_benefits:
|
||||||
return <CurrentBenefitsBlock {...componentProps} />
|
return <CurrentBenefitsBlock {...componentProps} />
|
||||||
case DynamicContentComponents.next_benefits:
|
case DynamicContentComponents.next_benefits:
|
||||||
|
|||||||
@@ -11,12 +11,13 @@ export type CurrentLevelProps = {
|
|||||||
subtitle?: string
|
subtitle?: string
|
||||||
link: { text: string; href: string } | null
|
link: { text: string; href: string } | null
|
||||||
}
|
}
|
||||||
|
import { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage"
|
||||||
|
|
||||||
export default async function CurrentBenefitsBlock({
|
export default async function CurrentBenefitsBlock({
|
||||||
title,
|
title,
|
||||||
subtitle,
|
subtitle,
|
||||||
link,
|
link,
|
||||||
}: CurrentLevelProps) {
|
}: AccountPageComponentProps) {
|
||||||
const benefits = await serverClient().user.benefits.current()
|
const benefits = await serverClient().user.benefits.current()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -7,18 +7,13 @@ import Button from "@/components/TempDesignSystem/Button"
|
|||||||
import Title from "@/components/Title"
|
import Title from "@/components/Title"
|
||||||
|
|
||||||
import styles from "./next.module.css"
|
import styles from "./next.module.css"
|
||||||
|
import { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage"
|
||||||
export type NextLevelProps = {
|
|
||||||
title: string
|
|
||||||
subtitle?: string
|
|
||||||
link: { href: string; text: string } | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export default async function NextLevelBenefitsBlock({
|
export default async function NextLevelBenefitsBlock({
|
||||||
title,
|
title,
|
||||||
subtitle,
|
subtitle,
|
||||||
link,
|
link,
|
||||||
}: NextLevelProps) {
|
}: AccountPageComponentProps) {
|
||||||
const { nextLevel, perks } = await serverClient().user.benefits.nextLevel()
|
const { nextLevel, perks } = await serverClient().user.benefits.nextLevel()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -11,21 +11,15 @@ import ShowMoreButton from "../ShowMoreButton"
|
|||||||
import StayList from "../StayList"
|
import StayList from "../StayList"
|
||||||
import EmptyPreviousStaysBlock from "./EmptyPreviousStays"
|
import EmptyPreviousStaysBlock from "./EmptyPreviousStays"
|
||||||
|
|
||||||
|
import { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage"
|
||||||
import type { Page } from "@/types/components/myPages/myStays/page"
|
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({
|
export default function PreviousStays({
|
||||||
lang,
|
lang,
|
||||||
title,
|
title,
|
||||||
subtitle,
|
subtitle,
|
||||||
link,
|
link,
|
||||||
}: PreviousStaysProps) {
|
}: AccountPageComponentProps) {
|
||||||
const { data, isFetching, fetchNextPage, hasNextPage } =
|
const { data, isFetching, fetchNextPage, hasNextPage } =
|
||||||
trpc.user.stays.previous.useInfiniteQuery(
|
trpc.user.stays.previous.useInfiniteQuery(
|
||||||
{},
|
{},
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { Lang } from "@/constants/languages"
|
|
||||||
import { serverClient } from "@/lib/trpc/server"
|
import { serverClient } from "@/lib/trpc/server"
|
||||||
|
|
||||||
import Header from "../Header"
|
import Header from "../Header"
|
||||||
@@ -7,19 +6,14 @@ import EmptyUpcomingStaysBlock from "./EmptyUpcomingStays"
|
|||||||
|
|
||||||
import styles from "./soonest.module.css"
|
import styles from "./soonest.module.css"
|
||||||
|
|
||||||
type UpcomingStaysProps = {
|
import { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage"
|
||||||
lang: Lang
|
|
||||||
title: string
|
|
||||||
subtitle?: string
|
|
||||||
link: { text: string; href: string } | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export default async function UpcomingStays({
|
export default async function UpcomingStays({
|
||||||
lang,
|
lang,
|
||||||
title,
|
title,
|
||||||
subtitle,
|
subtitle,
|
||||||
link,
|
link,
|
||||||
}: UpcomingStaysProps) {
|
}: AccountPageComponentProps) {
|
||||||
const stays = await serverClient().user.stays.soonestUpcoming()
|
const stays = await serverClient().user.stays.soonestUpcoming()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -11,21 +11,15 @@ import ShowMoreButton from "../ShowMoreButton"
|
|||||||
import StayList from "../StayList"
|
import StayList from "../StayList"
|
||||||
import EmptyUpcomingStaysBlock from "./EmptyUpcomingStays"
|
import EmptyUpcomingStaysBlock from "./EmptyUpcomingStays"
|
||||||
|
|
||||||
|
import { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage"
|
||||||
import type { Page } from "@/types/components/myPages/myStays/page"
|
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({
|
export default function UpcomingStays({
|
||||||
lang,
|
lang,
|
||||||
title,
|
title,
|
||||||
subtitle,
|
subtitle,
|
||||||
link,
|
link,
|
||||||
}: UpcomingStaysProps) {
|
}: AccountPageComponentProps) {
|
||||||
const { data, hasNextPage, isFetching, fetchNextPage } =
|
const { data, hasNextPage, isFetching, fetchNextPage } =
|
||||||
trpc.user.stays.upcoming.useInfiniteQuery(
|
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"
|
import { ReactNode } from "react"
|
||||||
|
|
||||||
export type ShortcutsProps = {
|
export type ShortcutsProps = {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export type HeaderProps = {
|
export type HeaderProps = {
|
||||||
title: string
|
title: string
|
||||||
subtitle?: string
|
subtitle?: string
|
||||||
link: { href: string; text: string } | null
|
link?: { href: string; text: string }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user