fix: rename BedTypeEnums
This commit is contained in:
@@ -11,7 +11,7 @@ import Counter from "../Counter"
|
||||
|
||||
import styles from "./adult-selector.module.css"
|
||||
|
||||
import { BedTypeEnum } from "@/types/components/bookingWidget/enums"
|
||||
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
|
||||
import {
|
||||
AdultSelectorProps,
|
||||
Child,
|
||||
@@ -40,14 +40,14 @@ export default function AdultSelector({ roomIndex = 0 }: AdultSelectorProps) {
|
||||
setValue(`rooms.${roomIndex}.adults`, adults - 1)
|
||||
if (childrenInAdultsBed > adults) {
|
||||
const toUpdateIndex = child.findIndex(
|
||||
(child: Child) => child.bed == BedTypeEnum.IN_ADULTS_BED
|
||||
(child: Child) => child.bed == ChildBedMapEnum.IN_ADULTS_BED
|
||||
)
|
||||
if (toUpdateIndex != -1) {
|
||||
setValue(
|
||||
`rooms.${roomIndex}.children.${toUpdateIndex}.bed`,
|
||||
child[toUpdateIndex].age < 3
|
||||
? BedTypeEnum.IN_CRIB
|
||||
: BedTypeEnum.IN_EXTRA_BED
|
||||
? ChildBedMapEnum.IN_CRIB
|
||||
: ChildBedMapEnum.IN_EXTRA_BED
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import Caption from "@/components/TempDesignSystem/Text/Caption"
|
||||
|
||||
import styles from "./child-selector.module.css"
|
||||
|
||||
import { BedTypeEnum } from "@/types/components/bookingWidget/enums"
|
||||
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
|
||||
import {
|
||||
ChildBed,
|
||||
ChildInfoSelectorProps,
|
||||
@@ -59,9 +59,9 @@ export default function ChildInfoSelector({
|
||||
}
|
||||
|
||||
function updateSelectedBed(bed: number) {
|
||||
if (bed == BedTypeEnum.IN_ADULTS_BED) {
|
||||
if (bed == ChildBedMapEnum.IN_ADULTS_BED) {
|
||||
increaseChildInAdultsBed(roomIndex)
|
||||
} else if (child.bed == BedTypeEnum.IN_ADULTS_BED) {
|
||||
} else if (child.bed == ChildBedMapEnum.IN_ADULTS_BED) {
|
||||
decreaseChildInAdultsBed(roomIndex)
|
||||
}
|
||||
updateChildBed(bed, roomIndex, index)
|
||||
@@ -71,15 +71,15 @@ export default function ChildInfoSelector({
|
||||
const allBedTypes: ChildBed[] = [
|
||||
{
|
||||
label: intl.formatMessage({ id: "In adults bed" }),
|
||||
value: BedTypeEnum.IN_ADULTS_BED,
|
||||
value: ChildBedMapEnum.IN_ADULTS_BED,
|
||||
},
|
||||
{
|
||||
label: intl.formatMessage({ id: "In crib" }),
|
||||
value: BedTypeEnum.IN_CRIB,
|
||||
value: ChildBedMapEnum.IN_CRIB,
|
||||
},
|
||||
{
|
||||
label: intl.formatMessage({ id: "In extra bed" }),
|
||||
value: BedTypeEnum.IN_EXTRA_BED,
|
||||
value: ChildBedMapEnum.IN_EXTRA_BED,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { ChildBedTypeEnum } from "@/constants/booking"
|
||||
|
||||
import { getFormattedUrlQueryParams } from "@/utils/url"
|
||||
|
||||
import { BedTypeEnum } from "@/types/components/bookingWidget/enums"
|
||||
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
|
||||
import { BookingData } from "@/types/components/hotelReservation/enterDetails/bookingData"
|
||||
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
||||
import type {
|
||||
@@ -12,13 +14,14 @@ export function getHotelReservationQueryParams(searchParams: URLSearchParams) {
|
||||
return getFormattedUrlQueryParams(searchParams, {
|
||||
adults: "number",
|
||||
age: "number",
|
||||
bed: ChildBedMapEnum,
|
||||
}) as SelectRateSearchParams
|
||||
}
|
||||
|
||||
const bedTypeMap: Record<number, string> = {
|
||||
[BedTypeEnum.IN_ADULTS_BED]: "ParentsBed",
|
||||
[BedTypeEnum.IN_CRIB]: "Crib",
|
||||
[BedTypeEnum.IN_EXTRA_BED]: "ExtraBed",
|
||||
export const bedTypeMap: Record<number, ChildBedTypeEnum> = {
|
||||
[ChildBedMapEnum.IN_ADULTS_BED]: ChildBedTypeEnum.ParentsBed,
|
||||
[ChildBedMapEnum.IN_CRIB]: ChildBedTypeEnum.Crib,
|
||||
[ChildBedMapEnum.IN_EXTRA_BED]: ChildBedTypeEnum.ExtraBed,
|
||||
}
|
||||
|
||||
export function generateChildrenString(children: Child[]): string {
|
||||
@@ -31,17 +34,6 @@ export function generateChildrenString(children: Child[]): string {
|
||||
.join(",")}]`
|
||||
}
|
||||
|
||||
export function mapChildrenFromString(rawChildrenString: string) {
|
||||
const children = rawChildrenString.split(",")
|
||||
return children.map((child) => {
|
||||
const [age, bed] = child.split(":")
|
||||
return {
|
||||
age: parseInt(age),
|
||||
bed: BedTypeEnum[bed as keyof typeof BedTypeEnum],
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function getQueryParamsForEnterDetails(
|
||||
searchParams: URLSearchParams
|
||||
): BookingData {
|
||||
@@ -49,10 +41,12 @@ export function getQueryParamsForEnterDetails(
|
||||
|
||||
const { room } = selectRoomParamsObject
|
||||
return {
|
||||
...selectRoomParamsObject,
|
||||
fromDate: selectRoomParamsObject.fromDate,
|
||||
toDate: selectRoomParamsObject.toDate,
|
||||
hotel: selectRoomParamsObject.hotel,
|
||||
rooms: room.map((room) => ({
|
||||
adults: room.adults, // TODO: Handle multiple rooms
|
||||
child: room.child, // TODO: Handle multiple rooms and children
|
||||
children: room.child, // TODO: Handle multiple rooms and children
|
||||
roomTypeCode: room.roomtype,
|
||||
rateCode: room.ratecode,
|
||||
packages: room.packages?.split(",") as RoomPackageCodeEnum[],
|
||||
|
||||
Reference in New Issue
Block a user