Merged in feat/sw-1681-add-breakfast (pull request #1635)

Feat/sw-1681 add breakfast
This implements the add breakfast flow

Approved-by: Pontus Dreij
This commit is contained in:
Niclas Edenvin
2025-03-27 12:40:54 +00:00
parent bed490d79a
commit 8eec465afa
15 changed files with 508 additions and 78 deletions

View File

@@ -10,6 +10,7 @@ import type {
Ancillary,
SelectedAncillary,
} from "@/types/components/myPages/myStay/ancillaries"
import { BreakfastPackageEnum } from "@/types/enums/breakfast"
import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation"
export enum AncillaryStepEnum {
@@ -29,6 +30,15 @@ type Steps = {
[AncillaryStepEnum.confirmation]: Step
}
export type BreakfastData = {
nrOfAdults: number
nrOfPayingChildren: number
nrOfFreeChildren: number
priceAdult: number
priceChild: number
currency: string
}
export interface AddAncillaryState {
currentStep: number
steps: Steps
@@ -41,6 +51,9 @@ export interface AddAncillaryState {
openModal: VoidFunction
closeModal: VoidFunction
prevStep: VoidFunction
breakfastData: BreakfastData | null
setBreakfastData: (breakfastData: BreakfastData | null) => void
isBreakfast: boolean
isOpen: boolean
selectedAncillary: SelectedAncillary | null
selectAncillary: (ancillary: SelectedAncillary) => void
@@ -95,6 +108,8 @@ export const createAddAncillaryStore = (
ancillariesBySelectedCategory,
currentStep: AncillaryStepEnum.selectAncillary,
selectedAncillary: null,
breakfastData: null,
isBreakfast: false,
isOpen: false,
steps,
openModal: () =>
@@ -189,6 +204,14 @@ export const createAddAncillaryStore = (
}
state.selectedAncillary = ancillary
state.currentStep = AncillaryStepEnum.selectQuantity
state.isBreakfast =
ancillary.id === BreakfastPackageEnum.ANCILLARY_REGULAR_BREAKFAST
})
),
setBreakfastData: (breakfastData) =>
set(
produce((state: AddAncillaryState) => {
state.breakfastData = breakfastData
})
),
}))