73 lines
2.2 KiB
TypeScript
73 lines
2.2 KiB
TypeScript
import { notFound } from "next/navigation"
|
|
|
|
import { getProfileSafely } from "@/lib/trpc/memoizedRequests"
|
|
import { serverClient } from "@/lib/trpc/server"
|
|
|
|
import BedType from "@/components/HotelReservation/EnterDetails/BedType"
|
|
import Breakfast from "@/components/HotelReservation/EnterDetails/Breakfast"
|
|
import Details from "@/components/HotelReservation/EnterDetails/Details"
|
|
import HistoryStateManager from "@/components/HotelReservation/EnterDetails/HistoryStateManager"
|
|
import SectionAccordion from "@/components/HotelReservation/EnterDetails/SectionAccordion"
|
|
import Payment from "@/components/HotelReservation/SelectRate/Payment"
|
|
import { getIntl } from "@/i18n"
|
|
|
|
import { StepEnum } from "@/types/components/enterDetails/step"
|
|
import type { LangParams, PageArgs } from "@/types/params"
|
|
|
|
function isValidStep(step: string): step is StepEnum {
|
|
return Object.values(StepEnum).includes(step as StepEnum)
|
|
}
|
|
|
|
export default async function StepPage({
|
|
params,
|
|
}: PageArgs<LangParams & { step: StepEnum }>) {
|
|
const { step, lang } = params
|
|
|
|
const intl = await getIntl()
|
|
|
|
const hotel = await serverClient().hotel.hotelData.get({
|
|
hotelId: "811",
|
|
language: lang,
|
|
})
|
|
|
|
const user = await getProfileSafely()
|
|
|
|
if (!isValidStep(step) || !hotel) {
|
|
return notFound()
|
|
}
|
|
|
|
return (
|
|
<section>
|
|
<HistoryStateManager />
|
|
<SectionAccordion
|
|
header="Select bed"
|
|
step={StepEnum.selectBed}
|
|
label={intl.formatMessage({ id: "Request bedtype" })}
|
|
>
|
|
<BedType />
|
|
</SectionAccordion>
|
|
<SectionAccordion
|
|
header="Food options"
|
|
step={StepEnum.breakfast}
|
|
label={intl.formatMessage({ id: "Select breakfast options" })}
|
|
>
|
|
<Breakfast />
|
|
</SectionAccordion>
|
|
<SectionAccordion
|
|
header="Details"
|
|
step={StepEnum.details}
|
|
label={intl.formatMessage({ id: "Enter your details" })}
|
|
>
|
|
<Details user={user} />
|
|
</SectionAccordion>
|
|
<SectionAccordion
|
|
header="Payment"
|
|
step={StepEnum.payment}
|
|
label={intl.formatMessage({ id: "Select payment method" })}
|
|
>
|
|
<Payment hotel={hotel.data.attributes} />
|
|
</SectionAccordion>
|
|
</section>
|
|
)
|
|
}
|