feat: get breakfast package from API
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { notFound } from "next/navigation"
|
||||
import { notFound, redirect } from "next/navigation"
|
||||
|
||||
import {
|
||||
getBreakfastPackages,
|
||||
getCreditCardsSafely,
|
||||
getHotelData,
|
||||
getProfileSafely,
|
||||
@@ -17,22 +18,32 @@ import { getIntl } from "@/i18n"
|
||||
import { StepEnum } from "@/types/components/enterDetails/step"
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export function preload() {
|
||||
void getProfileSafely()
|
||||
void getCreditCardsSafely()
|
||||
}
|
||||
|
||||
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
|
||||
searchParams,
|
||||
}: PageArgs<LangParams & { step: StepEnum }, { hotel: string }>) {
|
||||
if (!searchParams.hotel) {
|
||||
redirect(`/${params.lang}`)
|
||||
}
|
||||
void getBreakfastPackages(searchParams.hotel)
|
||||
|
||||
const intl = await getIntl()
|
||||
|
||||
const hotel = await getHotelData("811", lang)
|
||||
const hotel = await getHotelData(searchParams.hotel, params.lang)
|
||||
const user = await getProfileSafely()
|
||||
const savedCreditCards = await getCreditCardsSafely()
|
||||
const breakfastPackages = await getBreakfastPackages(searchParams.hotel)
|
||||
|
||||
if (!isValidStep(step) || !hotel) {
|
||||
if (!isValidStep(params.step) || !hotel) {
|
||||
return notFound()
|
||||
}
|
||||
|
||||
@@ -51,7 +62,7 @@ export default async function StepPage({
|
||||
step={StepEnum.breakfast}
|
||||
label={intl.formatMessage({ id: "Select breakfast options" })}
|
||||
>
|
||||
<Breakfast />
|
||||
<Breakfast packages={breakfastPackages} />
|
||||
</SectionAccordion>
|
||||
<SectionAccordion
|
||||
header="Details"
|
||||
|
||||
Reference in New Issue
Block a user