feat: get breakfast package from API
This commit is contained in:
@@ -3,21 +3,22 @@ import { createContext, useContext } from "react"
|
||||
import { create, useStore } from "zustand"
|
||||
|
||||
import { bedTypeSchema } from "@/components/HotelReservation/EnterDetails/BedType/schema"
|
||||
import { breakfastSchema } from "@/components/HotelReservation/EnterDetails/Breakfast/schema"
|
||||
import { breakfastStoreSchema } from "@/components/HotelReservation/EnterDetails/Breakfast/schema"
|
||||
import { detailsSchema } from "@/components/HotelReservation/EnterDetails/Details/schema"
|
||||
|
||||
import { BreakfastPackage } from "@/types/components/enterDetails/breakfast"
|
||||
import { DetailsSchema } from "@/types/components/enterDetails/details"
|
||||
import { SidePeekEnum } from "@/types/components/enterDetails/sidePeek"
|
||||
import { StepEnum } from "@/types/components/enterDetails/step"
|
||||
import { bedTypeEnum } from "@/types/enums/bedType"
|
||||
import { breakfastEnum } from "@/types/enums/breakfast"
|
||||
import { BedTypeEnum } from "@/types/enums/bedType"
|
||||
import { BreakfastPackageEnum } from "@/types/enums/breakfast"
|
||||
|
||||
const SESSION_STORAGE_KEY = "enterDetails"
|
||||
|
||||
interface EnterDetailsState {
|
||||
data: {
|
||||
bedType: bedTypeEnum | undefined
|
||||
breakfast: breakfastEnum | undefined
|
||||
bedType: BedTypeEnum | undefined
|
||||
breakfast: BreakfastPackage | BreakfastPackageEnum.NO_BREAKFAST | undefined
|
||||
} & DetailsSchema
|
||||
steps: StepEnum[]
|
||||
currentStep: StepEnum
|
||||
@@ -26,7 +27,7 @@ interface EnterDetailsState {
|
||||
completeStep: (updatedData: Partial<EnterDetailsState["data"]>) => void
|
||||
navigate: (
|
||||
step: StepEnum,
|
||||
updatedData?: Record<string, string | boolean>
|
||||
updatedData?: Record<string, string | boolean | BreakfastPackage>
|
||||
) => void
|
||||
setCurrentStep: (step: StepEnum) => void
|
||||
openSidePeek: (key: SidePeekEnum | null) => void
|
||||
@@ -75,7 +76,7 @@ export function initEditDetailsState(currentStep: StepEnum) {
|
||||
initialData = { ...initialData, ...validatedBedType.data }
|
||||
isValid[StepEnum.selectBed] = true
|
||||
}
|
||||
const validatedBreakfast = breakfastSchema.safeParse(inputData)
|
||||
const validatedBreakfast = breakfastStoreSchema.safeParse(inputData)
|
||||
if (validatedBreakfast.success) {
|
||||
validPaths.push(StepEnum.details)
|
||||
initialData = { ...initialData, ...validatedBreakfast.data }
|
||||
|
||||
Reference in New Issue
Block a user