Files
web/apps/scandic-web/components/Blocks/DynamicContent/Stays/UpcomingStays/index.tsx
Chuma Mcphoy (We Ahead) 0b28893e71 Merged in feat/LOY-422-new-upcoming-stays (pull request #3121)
feat(LOY-422): Upcoming Stays Redesign

* feat(LOY-422): Upcoming Stays Redesign

* feat(LOY-422): Carousel next/previous arrows

* chore(LOY-422): add new material icon

* refactor(LOY-422): restructure new and old upcoming stays

* fix(LOY-422): handle less than 1 case

* chore(LOY-422): remove uneeded id

* chore(LOY-422): remove intl label for date edge case


Approved-by: Matilda Landström
2025-11-13 13:05:24 +00:00

52 lines
1.5 KiB
TypeScript

import { env } from "@/env/server"
import { serverClient } from "@/lib/trpc/server"
import { Section } from "@/components/Section"
import { SectionHeader } from "@/components/Section/Header"
import SectionLink from "@/components/Section/Link"
import EmptyUpcomingStaysBlock from "../EmptyUpcomingStays"
import UpcomingStaysCarousel from "./Carousel"
import ClientUpcomingStays from "./Client"
import styles from "./upcoming.module.css"
import type { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage"
export default async function UpcomingStays({
title,
link,
}: AccountPageComponentProps) {
const caller = await serverClient()
const initialUpcomingStays = await caller.user.stays.upcoming({
limit: 6,
})
const hasStays =
initialUpcomingStays?.data && initialUpcomingStays.data.length > 0
if (env.NEW_STAYS_ON_MY_PAGES) {
if (!hasStays) return null
return (
<Section className={styles.container}>
{title && <SectionHeader heading={title} link={link} />}
<UpcomingStaysCarousel initialUpcomingStays={initialUpcomingStays} />
<SectionLink link={link} variant="mobile" />
</Section>
)
}
return (
<Section className={styles.container}>
{title && <SectionHeader heading={title} link={link} />}
{hasStays ? (
<ClientUpcomingStays initialUpcomingStays={initialUpcomingStays} />
) : (
<EmptyUpcomingStaysBlock />
)}
<SectionLink link={link} variant="mobile" />
</Section>
)
}