Files
web/components/MyPages/Blocks/Stays/Soonest/index.tsx
2024-06-18 16:21:06 +02:00

42 lines
1.1 KiB
TypeScript

import { serverClient } from "@/lib/trpc/server"
import SectionContainer from "@/components/Section/Container"
import Header from "@/components/Section/Header"
import Grids from "@/components/TempDesignSystem/Grids"
import StayCard from "../StayCard"
import EmptyUpcomingStaysBlock from "./EmptyUpcomingStays"
import { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage"
export default async function SoonestStays({
lang,
title,
subtitle,
link,
}: AccountPageComponentProps) {
const response = await serverClient().user.stays.upcoming({ limit: 3 })
if (!response?.data) {
return null
}
return (
<SectionContainer>
<Header title={title} subtitle={subtitle} link={link} />
{response.data.length ? (
<Grids.Stackable>
{response.data.map((stay) => (
<StayCard
key={stay.attributes.confirmationNumber}
lang={lang}
stay={stay}
/>
))}
</Grids.Stackable>
) : (
<EmptyUpcomingStaysBlock />
)}
</SectionContainer>
)
}