Merge branch 'master' into feature/tracking
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
getQueryParamsForEnterDetails,
|
||||
} from "@/components/HotelReservation/SelectRate/RoomSelection/utils"
|
||||
|
||||
import type { BedTypeSchema } from "@/types/components/hotelReservation/enterDetails/bedType"
|
||||
import { BookingData } from "@/types/components/hotelReservation/enterDetails/bookingData"
|
||||
import { BreakfastPackage } from "@/types/components/hotelReservation/enterDetails/breakfast"
|
||||
import { DetailsSchema } from "@/types/components/hotelReservation/enterDetails/details"
|
||||
@@ -24,7 +25,7 @@ const SESSION_STORAGE_KEY = "enterDetails"
|
||||
|
||||
interface EnterDetailsState {
|
||||
userData: {
|
||||
bedType: string | undefined
|
||||
bedType: BedTypeSchema | undefined
|
||||
breakfast: BreakfastPackage | BreakfastPackageEnum.NO_BREAKFAST | undefined
|
||||
} & DetailsSchema
|
||||
roomData: BookingData
|
||||
@@ -35,7 +36,10 @@ interface EnterDetailsState {
|
||||
completeStep: (updatedData: Partial<EnterDetailsState["userData"]>) => void
|
||||
navigate: (
|
||||
step: StepEnum,
|
||||
updatedData?: Record<string, string | boolean | BreakfastPackage>
|
||||
updatedData?: Record<
|
||||
string,
|
||||
string | boolean | number | BreakfastPackage | BedTypeSchema
|
||||
>
|
||||
) => void
|
||||
setCurrentStep: (step: StepEnum) => void
|
||||
}
|
||||
@@ -70,6 +74,7 @@ export function initEditDetailsState(
|
||||
zipCode: "",
|
||||
dateOfBirth: undefined,
|
||||
termsAccepted: false,
|
||||
membershipNo: "",
|
||||
}
|
||||
|
||||
let inputUserData = {}
|
||||
@@ -153,7 +158,6 @@ export function initEditDetailsState(
|
||||
const nextStep =
|
||||
state.steps[state.steps.indexOf(state.currentStep) + 1]
|
||||
|
||||
// @ts-expect-error: ts has a hard time understanding that "false | true" equals "boolean"
|
||||
state.userData = {
|
||||
...state.userData,
|
||||
...updatedData,
|
||||
|
||||
@@ -4,7 +4,7 @@ import { produce } from "immer"
|
||||
import { createContext, useContext } from "react"
|
||||
import { create, useStore } from "zustand"
|
||||
|
||||
import { BedTypeEnum } from "@/types/components/bookingWidget/enums"
|
||||
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
|
||||
import {
|
||||
Child,
|
||||
GuestsRoom,
|
||||
@@ -41,15 +41,15 @@ export function validateBedTypes(data: extendedGuestsRoom[]) {
|
||||
room.child.forEach((child) => {
|
||||
const allowedBedTypes: number[] = []
|
||||
if (child.age <= 5 && room.adults >= room.childrenInAdultsBed) {
|
||||
allowedBedTypes.push(BedTypeEnum.IN_ADULTS_BED)
|
||||
allowedBedTypes.push(ChildBedMapEnum.IN_ADULTS_BED)
|
||||
} else if (child.age <= 5) {
|
||||
room.childrenInAdultsBed = room.childrenInAdultsBed - 1
|
||||
}
|
||||
if (child.age < 3) {
|
||||
allowedBedTypes.push(BedTypeEnum.IN_CRIB)
|
||||
allowedBedTypes.push(ChildBedMapEnum.IN_CRIB)
|
||||
}
|
||||
if (child.age > 2) {
|
||||
allowedBedTypes.push(BedTypeEnum.IN_EXTRA_BED)
|
||||
allowedBedTypes.push(ChildBedMapEnum.IN_EXTRA_BED)
|
||||
}
|
||||
if (!allowedBedTypes.includes(child.bed)) {
|
||||
child.bed = allowedBedTypes[0]
|
||||
@@ -84,7 +84,7 @@ export function initGuestsRoomsState(initData?: GuestsRoom[]) {
|
||||
inputData.rooms = initData.map((room) => {
|
||||
const childrenInAdultsBed = room.child
|
||||
? room.child.reduce((acc, child) => {
|
||||
acc = acc + (child.bed == BedTypeEnum.IN_ADULTS_BED ? 1 : 0)
|
||||
acc = acc + (child.bed == ChildBedMapEnum.IN_ADULTS_BED ? 1 : 0)
|
||||
return acc
|
||||
}, 0)
|
||||
: 0
|
||||
@@ -121,13 +121,13 @@ export function initGuestsRoomsState(initData?: GuestsRoom[]) {
|
||||
state.rooms[roomIndex].adults
|
||||
) {
|
||||
const toUpdateIndex = state.rooms[roomIndex].child.findIndex(
|
||||
(child) => child.bed == BedTypeEnum.IN_ADULTS_BED
|
||||
(child) => child.bed == ChildBedMapEnum.IN_ADULTS_BED
|
||||
)
|
||||
if (toUpdateIndex != -1) {
|
||||
state.rooms[roomIndex].child[toUpdateIndex].bed =
|
||||
state.rooms[roomIndex].child[toUpdateIndex].age < 3
|
||||
? BedTypeEnum.IN_CRIB
|
||||
: BedTypeEnum.IN_EXTRA_BED
|
||||
? ChildBedMapEnum.IN_CRIB
|
||||
: ChildBedMapEnum.IN_EXTRA_BED
|
||||
state.rooms[roomIndex].childrenInAdultsBed =
|
||||
state.rooms[roomIndex].adults
|
||||
}
|
||||
@@ -151,7 +151,7 @@ export function initGuestsRoomsState(initData?: GuestsRoom[]) {
|
||||
if (
|
||||
roomChildren.length &&
|
||||
roomChildren[roomChildren.length - 1].bed ==
|
||||
BedTypeEnum.IN_ADULTS_BED
|
||||
ChildBedMapEnum.IN_ADULTS_BED
|
||||
) {
|
||||
state.rooms[roomIndex].childrenInAdultsBed =
|
||||
state.rooms[roomIndex].childrenInAdultsBed - 1
|
||||
|
||||
Reference in New Issue
Block a user