fix: rename BedTypeEnums
This commit is contained in:
@@ -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