fix: rename children to childrenInRoom
This commit is contained in:
@@ -23,8 +23,8 @@ export default async function SelectHotelMapPage({
|
|||||||
const {
|
const {
|
||||||
city,
|
city,
|
||||||
adultsInRoom,
|
adultsInRoom,
|
||||||
|
childrenInRoomString,
|
||||||
childrenInRoom,
|
childrenInRoom,
|
||||||
childrenInRoomArray,
|
|
||||||
selectHotelParams,
|
selectHotelParams,
|
||||||
} = searchDetails
|
} = searchDetails
|
||||||
|
|
||||||
@@ -41,8 +41,8 @@ export default async function SelectHotelMapPage({
|
|||||||
city={city}
|
city={city}
|
||||||
selectHotelParams={selectHotelParams}
|
selectHotelParams={selectHotelParams}
|
||||||
adultsInRoom={adultsInRoom}
|
adultsInRoom={adultsInRoom}
|
||||||
|
childrenInRoomString={childrenInRoomString}
|
||||||
childrenInRoom={childrenInRoom}
|
childrenInRoom={childrenInRoom}
|
||||||
child={childrenInRoomArray}
|
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</MapContainer>
|
</MapContainer>
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ export default async function SelectHotelPage({
|
|||||||
city,
|
city,
|
||||||
selectHotelParams,
|
selectHotelParams,
|
||||||
adultsInRoom,
|
adultsInRoom,
|
||||||
|
childrenInRoomString,
|
||||||
childrenInRoom,
|
childrenInRoom,
|
||||||
childrenInRoomArray,
|
|
||||||
} = searchDetails
|
} = searchDetails
|
||||||
|
|
||||||
if (!city) return notFound()
|
if (!city) return notFound()
|
||||||
@@ -30,13 +30,13 @@ export default async function SelectHotelPage({
|
|||||||
const reservationParams = {
|
const reservationParams = {
|
||||||
selectHotelParams,
|
selectHotelParams,
|
||||||
adultsInRoom,
|
adultsInRoom,
|
||||||
|
childrenInRoomString,
|
||||||
childrenInRoom,
|
childrenInRoom,
|
||||||
childrenInRoomArray,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Suspense
|
<Suspense
|
||||||
key={`${city.name}-${searchParams.fromDate}-${searchParams.toDate}-${adultsInRoom}-${childrenInRoom}`}
|
key={`${city.name}-${searchParams.fromDate}-${searchParams.toDate}-${adultsInRoom}-${childrenInRoomString}`}
|
||||||
fallback={<SelectHotelSkeleton />}
|
fallback={<SelectHotelSkeleton />}
|
||||||
>
|
>
|
||||||
<SelectHotel
|
<SelectHotel
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export default async function SelectRatePage({
|
|||||||
setLang(params.lang)
|
setLang(params.lang)
|
||||||
const searchDetails = await getHotelSearchDetails({ searchParams })
|
const searchDetails = await getHotelSearchDetails({ searchParams })
|
||||||
if (!searchDetails) return notFound()
|
if (!searchDetails) return notFound()
|
||||||
const { hotel, adultsInRoom, childrenInRoomArray, selectHotelParams } =
|
const { hotel, adultsInRoom, childrenInRoom, selectHotelParams } =
|
||||||
searchDetails
|
searchDetails
|
||||||
|
|
||||||
if (!hotel) return notFound()
|
if (!hotel) return notFound()
|
||||||
@@ -62,9 +62,9 @@ export default async function SelectRatePage({
|
|||||||
arrivalDate: format(arrivalDate, "yyyy-MM-dd"),
|
arrivalDate: format(arrivalDate, "yyyy-MM-dd"),
|
||||||
departureDate: format(departureDate, "yyyy-MM-dd"),
|
departureDate: format(departureDate, "yyyy-MM-dd"),
|
||||||
noOfAdults: adultsInRoom,
|
noOfAdults: adultsInRoom,
|
||||||
noOfChildren: childrenInRoomArray?.length,
|
noOfChildren: childrenInRoom?.length,
|
||||||
ageOfChildren: childrenInRoomArray?.map((c) => c.age).join(","),
|
ageOfChildren: childrenInRoom?.map((c) => c.age).join(","),
|
||||||
childBedPreference: childrenInRoomArray
|
childBedPreference: childrenInRoom
|
||||||
?.map((c) => ChildBedMapEnum[c.bed])
|
?.map((c) => ChildBedMapEnum[c.bed])
|
||||||
.join("|"),
|
.join("|"),
|
||||||
noOfRooms: 1, // // TODO: Handle multiple rooms
|
noOfRooms: 1, // // TODO: Handle multiple rooms
|
||||||
@@ -88,7 +88,7 @@ export default async function SelectRatePage({
|
|||||||
fromDate={fromDate.toDate()}
|
fromDate={fromDate.toDate()}
|
||||||
toDate={toDate.toDate()}
|
toDate={toDate.toDate()}
|
||||||
adultCount={adultsInRoom}
|
adultCount={adultsInRoom}
|
||||||
childArray={childrenInRoomArray}
|
childArray={childrenInRoom}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Suspense key={hotelId} fallback={<RoomsContainerSkeleton />}>
|
<Suspense key={hotelId} fallback={<RoomsContainerSkeleton />}>
|
||||||
@@ -98,7 +98,7 @@ export default async function SelectRatePage({
|
|||||||
fromDate={fromDate.toDate()}
|
fromDate={fromDate.toDate()}
|
||||||
toDate={toDate.toDate()}
|
toDate={toDate.toDate()}
|
||||||
adultCount={adultsInRoom}
|
adultCount={adultsInRoom}
|
||||||
childArray={childrenInRoomArray}
|
childArray={childrenInRoom}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
<Suspense fallback={null}>
|
<Suspense fallback={null}>
|
||||||
|
|||||||
@@ -64,13 +64,20 @@ export default async function StepPage({
|
|||||||
const {
|
const {
|
||||||
hotelId,
|
hotelId,
|
||||||
rooms: [
|
rooms: [
|
||||||
{ adults, children, roomTypeCode, rateCode, packages: packageCodes },
|
{
|
||||||
|
adults,
|
||||||
|
childrenInRoom,
|
||||||
|
roomTypeCode,
|
||||||
|
rateCode,
|
||||||
|
packages: packageCodes,
|
||||||
|
},
|
||||||
], // TODO: Handle multiple rooms
|
], // TODO: Handle multiple rooms
|
||||||
fromDate,
|
fromDate,
|
||||||
toDate,
|
toDate,
|
||||||
} = booking
|
} = booking
|
||||||
|
|
||||||
const childrenAsString = children && generateChildrenString(children)
|
const childrenAsString =
|
||||||
|
childrenInRoom && generateChildrenString(childrenInRoom)
|
||||||
const breakfastInput = { adults, fromDate, hotelId, toDate }
|
const breakfastInput = { adults, fromDate, hotelId, toDate }
|
||||||
const selectedRoomAvailabilityInput = {
|
const selectedRoomAvailabilityInput = {
|
||||||
adults,
|
adults,
|
||||||
@@ -89,7 +96,7 @@ export default async function StepPage({
|
|||||||
if (packageCodes?.length) {
|
if (packageCodes?.length) {
|
||||||
void getPackages({
|
void getPackages({
|
||||||
adults,
|
adults,
|
||||||
children: children?.length,
|
children: childrenInRoom?.length,
|
||||||
endDate: toDate,
|
endDate: toDate,
|
||||||
hotelId,
|
hotelId,
|
||||||
packageCodes,
|
packageCodes,
|
||||||
@@ -100,7 +107,7 @@ export default async function StepPage({
|
|||||||
const packages = packageCodes
|
const packages = packageCodes
|
||||||
? await getPackages({
|
? await getPackages({
|
||||||
adults,
|
adults,
|
||||||
children: children?.length,
|
children: childrenInRoom?.length,
|
||||||
endDate: toDate,
|
endDate: toDate,
|
||||||
hotelId,
|
hotelId,
|
||||||
packageCodes,
|
packageCodes,
|
||||||
@@ -170,9 +177,11 @@ export default async function StepPage({
|
|||||||
arrivalDate: format(arrivalDate, "yyyy-MM-dd"),
|
arrivalDate: format(arrivalDate, "yyyy-MM-dd"),
|
||||||
departureDate: format(departureDate, "yyyy-MM-dd"),
|
departureDate: format(departureDate, "yyyy-MM-dd"),
|
||||||
noOfAdults: adults,
|
noOfAdults: adults,
|
||||||
noOfChildren: children?.length,
|
noOfChildren: childrenInRoom?.length,
|
||||||
ageOfChildren: children?.map((c) => c.age).join(","),
|
ageOfChildren: childrenInRoom?.map((c) => c.age).join(","),
|
||||||
childBedPreference: children?.map((c) => ChildBedMapEnum[c.bed]).join("|"),
|
childBedPreference: childrenInRoom
|
||||||
|
?.map((c) => ChildBedMapEnum[c.bed])
|
||||||
|
.join("|"),
|
||||||
noOfRooms: 1, // // TODO: Handle multiple rooms
|
noOfRooms: 1, // // TODO: Handle multiple rooms
|
||||||
duration: differenceInCalendarDays(departureDate, arrivalDate),
|
duration: differenceInCalendarDays(departureDate, arrivalDate),
|
||||||
leadTime: differenceInCalendarDays(arrivalDate, new Date()),
|
leadTime: differenceInCalendarDays(arrivalDate, new Date()),
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ interface HotelSearchDetails<T> {
|
|||||||
hotel: Location | null
|
hotel: Location | null
|
||||||
selectHotelParams: T
|
selectHotelParams: T
|
||||||
adultsInRoom: number
|
adultsInRoom: number
|
||||||
childrenInRoom?: string
|
childrenInRoomString?: string
|
||||||
childrenInRoomArray?: Child[]
|
childrenInRoom?: Child[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getHotelSearchDetails<
|
export async function getHotelSearchDetails<
|
||||||
@@ -48,17 +48,18 @@ export async function getHotelSearchDetails<
|
|||||||
if (!city && !hotel) return notFound()
|
if (!city && !hotel) return notFound()
|
||||||
|
|
||||||
let adultsInRoom = 1
|
let adultsInRoom = 1
|
||||||
let childrenInRoom: string | undefined = undefined
|
let childrenInRoomString: HotelSearchDetails<T>["childrenInRoomString"] =
|
||||||
let childrenInRoomArray: Child[] | undefined = undefined
|
undefined
|
||||||
|
let childrenInRoom: HotelSearchDetails<T>["childrenInRoom"] = undefined
|
||||||
|
|
||||||
const { rooms } = selectHotelParams
|
const { rooms } = selectHotelParams
|
||||||
|
|
||||||
if (rooms && rooms.length > 0) {
|
if (rooms && rooms.length > 0) {
|
||||||
adultsInRoom = rooms[0].adults // TODO: Handle multiple rooms
|
adultsInRoom = rooms[0].adults // TODO: Handle multiple rooms
|
||||||
childrenInRoom = rooms[0].children
|
childrenInRoomString = rooms[0].childrenInRoom
|
||||||
? generateChildrenString(rooms[0].children)
|
? generateChildrenString(rooms[0].childrenInRoom)
|
||||||
: undefined // TODO: Handle multiple rooms
|
: undefined // TODO: Handle multiple rooms
|
||||||
childrenInRoomArray = rooms[0].children ? rooms[0].children : undefined // TODO: Handle multiple rooms
|
childrenInRoom = rooms[0].childrenInRoom // TODO: Handle multiple rooms
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -66,7 +67,7 @@ export async function getHotelSearchDetails<
|
|||||||
hotel: hotel ?? null,
|
hotel: hotel ?? null,
|
||||||
selectHotelParams,
|
selectHotelParams,
|
||||||
adultsInRoom,
|
adultsInRoom,
|
||||||
|
childrenInRoomString,
|
||||||
childrenInRoom,
|
childrenInRoom,
|
||||||
childrenInRoomArray,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,13 +82,14 @@ export default function BookingWidgetClient({
|
|||||||
)
|
)
|
||||||
: undefined
|
: undefined
|
||||||
|
|
||||||
const defaultRoomsData = bookingWidgetSearchData?.rooms?.map((room) => ({
|
const defaultRoomsData: BookingWidgetSchema["rooms"] =
|
||||||
|
bookingWidgetSearchData?.rooms?.map((room) => ({
|
||||||
adults: room.adults,
|
adults: room.adults,
|
||||||
children: room.children ?? [],
|
childrenInRoom: room.childrenInRoom ?? [],
|
||||||
})) ?? [
|
})) ?? [
|
||||||
{
|
{
|
||||||
adults: 1,
|
adults: 1,
|
||||||
children: [],
|
childrenInRoom: [],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ export default function MobileToggleButton({
|
|||||||
return acc
|
return acc
|
||||||
}, 0)
|
}, 0)
|
||||||
const totalChildren = rooms.reduce((acc, room) => {
|
const totalChildren = rooms.reduce((acc, room) => {
|
||||||
if (room.children) {
|
if (room.childrenInRoom) {
|
||||||
acc = acc + room.children.length
|
acc = acc + room.childrenInRoom.length
|
||||||
}
|
}
|
||||||
return acc
|
return acc
|
||||||
}, 0)
|
}, 0)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import type { Location } from "@/types/trpc/routers/hotel/locations"
|
|||||||
export const guestRoomSchema = z
|
export const guestRoomSchema = z
|
||||||
.object({
|
.object({
|
||||||
adults: z.number().default(1),
|
adults: z.number().default(1),
|
||||||
children: z
|
childrenInRoom: z
|
||||||
.array(
|
.array(
|
||||||
z.object({
|
z.object({
|
||||||
age: z.number().min(0, "Age is required"),
|
age: z.number().min(0, "Age is required"),
|
||||||
@@ -16,11 +16,11 @@ export const guestRoomSchema = z
|
|||||||
.default([]),
|
.default([]),
|
||||||
})
|
})
|
||||||
.superRefine((value, ctx) => {
|
.superRefine((value, ctx) => {
|
||||||
const childrenInAdultsBed = value.children.filter(
|
const childrenInAdultsBed = value.childrenInRoom.filter(
|
||||||
(c) => c.bed === ChildBedMapEnum.IN_ADULTS_BED
|
(c) => c.bed === ChildBedMapEnum.IN_ADULTS_BED
|
||||||
)
|
)
|
||||||
if (value.adults < childrenInAdultsBed.length) {
|
if (value.adults < childrenInAdultsBed.length) {
|
||||||
const lastAdultBedIndex = value.children
|
const lastAdultBedIndex = value.childrenInRoom
|
||||||
.map((c) => c.bed)
|
.map((c) => c.bed)
|
||||||
.lastIndexOf(ChildBedMapEnum.IN_ADULTS_BED)
|
.lastIndexOf(ChildBedMapEnum.IN_ADULTS_BED)
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ export const guestRoomSchema = z
|
|||||||
code: z.ZodIssueCode.custom,
|
code: z.ZodIssueCode.custom,
|
||||||
message:
|
message:
|
||||||
"You cannot have more children in adults bed than adults in the room",
|
"You cannot have more children in adults bed than adults in the room",
|
||||||
path: ["child", lastAdultBedIndex],
|
path: ["childrenInRoom", lastAdultBedIndex],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ export default function ChildInfoSelector({
|
|||||||
index = 0,
|
index = 0,
|
||||||
roomIndex = 0,
|
roomIndex = 0,
|
||||||
}: ChildInfoSelectorProps) {
|
}: ChildInfoSelectorProps) {
|
||||||
const ageFieldName = `rooms.${roomIndex}.children.${index}.age`
|
const ageFieldName = `rooms.${roomIndex}.childrenInRoom.${index}.age`
|
||||||
const bedFieldName = `rooms.${roomIndex}.children.${index}.bed`
|
const bedFieldName = `rooms.${roomIndex}.childrenInRoom.${index}.bed`
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const ageLabel = intl.formatMessage({ id: "Age" })
|
const ageLabel = intl.formatMessage({ id: "Age" })
|
||||||
const bedLabel = intl.formatMessage({ id: "Bed" })
|
const bedLabel = intl.formatMessage({ id: "Bed" })
|
||||||
@@ -38,11 +38,11 @@ export default function ChildInfoSelector({
|
|||||||
const { setValue, formState } = useFormContext()
|
const { setValue, formState } = useFormContext()
|
||||||
|
|
||||||
function updateSelectedBed(bed: number) {
|
function updateSelectedBed(bed: number) {
|
||||||
setValue(`rooms.${roomIndex}.children.${index}.bed`, bed)
|
setValue(`rooms.${roomIndex}.childrenInRoom.${index}.bed`, bed)
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSelectedAge(age: number) {
|
function updateSelectedAge(age: number) {
|
||||||
setValue(`rooms.${roomIndex}.children.${index}.age`, age)
|
setValue(`rooms.${roomIndex}.childrenInRoom.${index}.age`, age)
|
||||||
const availableBedTypes = getAvailableBeds(age)
|
const availableBedTypes = getAvailableBeds(age)
|
||||||
updateSelectedBed(availableBedTypes[0].value)
|
updateSelectedBed(availableBedTypes[0].value)
|
||||||
}
|
}
|
||||||
@@ -76,8 +76,9 @@ export default function ChildInfoSelector({
|
|||||||
return availableBedTypes
|
return availableBedTypes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const roomErrors =
|
||||||
//@ts-expect-error: formState is typed with FormValues
|
//@ts-expect-error: formState is typed with FormValues
|
||||||
const roomErrors = formState.errors.rooms?.[roomIndex]?.children?.[index]
|
formState.errors.rooms?.[roomIndex]?.childrenInRoom?.[index]
|
||||||
|
|
||||||
const ageError = roomErrors?.age
|
const ageError = roomErrors?.age
|
||||||
const bedError = roomErrors?.bed
|
const bedError = roomErrors?.bed
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export default function ChildSelector({
|
|||||||
|
|
||||||
function increaseChildrenCount(roomIndex: number) {
|
function increaseChildrenCount(roomIndex: number) {
|
||||||
if (currentChildren.length < 5) {
|
if (currentChildren.length < 5) {
|
||||||
setValue(`rooms.${roomIndex}.children.${currentChildren.length}`, {
|
setValue(`rooms.${roomIndex}.childrenInRoom.${currentChildren.length}`, {
|
||||||
age: undefined,
|
age: undefined,
|
||||||
bed: undefined,
|
bed: undefined,
|
||||||
})
|
})
|
||||||
@@ -33,7 +33,7 @@ export default function ChildSelector({
|
|||||||
function decreaseChildrenCount(roomIndex: number) {
|
function decreaseChildrenCount(roomIndex: number) {
|
||||||
if (currentChildren.length > 0) {
|
if (currentChildren.length > 0) {
|
||||||
currentChildren.pop()
|
currentChildren.pop()
|
||||||
setValue(`rooms.${roomIndex}.children`, currentChildren)
|
setValue(`rooms.${roomIndex}.childrenInRoom`, currentChildren)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export default function GuestsRoomsPickerDialog({
|
|||||||
}, [trigger, onClose])
|
}, [trigger, onClose])
|
||||||
|
|
||||||
const handleAddRoom = useCallback(() => {
|
const handleAddRoom = useCallback(() => {
|
||||||
setValue("rooms", [...roomsValue, { adults: 1, children: [] }], {
|
setValue("rooms", [...roomsValue, { adults: 1, childrenInRoom: [] }], {
|
||||||
shouldValidate: true,
|
shouldValidate: true,
|
||||||
})
|
})
|
||||||
}, [roomsValue, setValue])
|
}, [roomsValue, setValue])
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export function GuestsRoom({
|
|||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const roomLabel = intl.formatMessage({ id: "Room" })
|
const roomLabel = intl.formatMessage({ id: "Room" })
|
||||||
|
|
||||||
const childrenInAdultsBed = room.children.filter(
|
const childrenInAdultsBed = room.childrenInRoom.filter(
|
||||||
(child) => child.bed === ChildBedMapEnum.IN_ADULTS_BED
|
(child) => child.bed === ChildBedMapEnum.IN_ADULTS_BED
|
||||||
).length
|
).length
|
||||||
|
|
||||||
@@ -38,13 +38,13 @@ export function GuestsRoom({
|
|||||||
<AdultSelector
|
<AdultSelector
|
||||||
roomIndex={index}
|
roomIndex={index}
|
||||||
currentAdults={room.adults}
|
currentAdults={room.adults}
|
||||||
currentChildren={room.children}
|
currentChildren={room.childrenInRoom}
|
||||||
childrenInAdultsBed={childrenInAdultsBed}
|
childrenInAdultsBed={childrenInAdultsBed}
|
||||||
/>
|
/>
|
||||||
<ChildSelector
|
<ChildSelector
|
||||||
roomIndex={index}
|
roomIndex={index}
|
||||||
currentAdults={room.adults}
|
currentAdults={room.adults}
|
||||||
currentChildren={room.children}
|
currentChildren={room.childrenInRoom}
|
||||||
childrenInAdultsBed={childrenInAdultsBed}
|
childrenInAdultsBed={childrenInAdultsBed}
|
||||||
/>
|
/>
|
||||||
{index !== 0 && (
|
{index !== 0 && (
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export default function GuestsRoomsPickerForm() {
|
|||||||
const [isOpen, setIsOpen] = useState(false)
|
const [isOpen, setIsOpen] = useState(false)
|
||||||
const [containerHeight, setContainerHeight] = useState(0)
|
const [containerHeight, setContainerHeight] = useState(0)
|
||||||
const childCount =
|
const childCount =
|
||||||
rooms[0] && rooms[0].children ? rooms[0].children.length : 0 // ToDo Update for multiroom later
|
rooms[0] && rooms[0].childrenInRoom ? rooms[0].childrenInRoom.length : 0 // ToDo Update for multiroom later
|
||||||
|
|
||||||
const htmlElement =
|
const htmlElement =
|
||||||
typeof window !== "undefined" ? document.querySelector("body") : null
|
typeof window !== "undefined" ? document.querySelector("body") : null
|
||||||
@@ -154,7 +154,7 @@ function Trigger({
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (rooms.some((room) => room.children.length > 0)) {
|
if (rooms.some((room) => room.childrenInRoom.length > 0)) {
|
||||||
parts.push(
|
parts.push(
|
||||||
intl.formatMessage(
|
intl.formatMessage(
|
||||||
{
|
{
|
||||||
@@ -162,7 +162,7 @@ function Trigger({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
totalChildren: rooms.reduce(
|
totalChildren: rooms.reduce(
|
||||||
(acc, room) => acc + room.children.length,
|
(acc, room) => acc + room.childrenInRoom.length,
|
||||||
0
|
0
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function BedTypeInfo({ hasMultipleBedTypes }: BedTypeInfoProps) {
|
|||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
|
|
||||||
const hasChildWithExtraBed = useEnterDetailsStore((state) =>
|
const hasChildWithExtraBed = useEnterDetailsStore((state) =>
|
||||||
state.booking.rooms[0].children?.some(
|
state.booking.rooms[0].childrenInRoom?.some(
|
||||||
(child) => Number(child.bed) === ChildBedMapEnum.IN_EXTRA_BED
|
(child) => Number(child.bed) === ChildBedMapEnum.IN_EXTRA_BED
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export default function Breakfast({ packages }: BreakfastProps) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const children = useEnterDetailsStore(
|
const children = useEnterDetailsStore(
|
||||||
(state) => state.booking.rooms[0].children
|
(state) => state.booking.rooms[0].childrenInRoom
|
||||||
)
|
)
|
||||||
|
|
||||||
const methods = useForm<BreakfastFormSchema>({
|
const methods = useForm<BreakfastFormSchema>({
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ export default function PaymentClient({
|
|||||||
checkOutDate: toDate,
|
checkOutDate: toDate,
|
||||||
rooms: rooms.map((room) => ({
|
rooms: rooms.map((room) => ({
|
||||||
adults: room.adults,
|
adults: room.adults,
|
||||||
childrenAges: room.children?.map((child) => ({
|
childrenAges: room.childrenInRoom?.map((child) => ({
|
||||||
age: child.age,
|
age: child.age,
|
||||||
bedType: bedTypeMap[parseInt(child.bed.toString())],
|
bedType: bedTypeMap[parseInt(child.bed.toString())],
|
||||||
})),
|
})),
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export default function PriceDetailsTable({
|
|||||||
useEnterDetailsStore(storeSelector)
|
useEnterDetailsStore(storeSelector)
|
||||||
|
|
||||||
// TODO: Update for Multiroom later
|
// TODO: Update for Multiroom later
|
||||||
const { adults, children } = booking.rooms[0]
|
const { adults, childrenInRoom } = booking.rooms[0]
|
||||||
const nights = getNights(booking.fromDate, booking.toDate)
|
const nights = getNights(booking.fromDate, booking.toDate)
|
||||||
|
|
||||||
const vatPercentage = vat / 100
|
const vatPercentage = vat / 100
|
||||||
@@ -121,13 +121,13 @@ export default function PriceDetailsTable({
|
|||||||
breakfast.localPrice.currency
|
breakfast.localPrice.currency
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{children?.length ? (
|
{childrenInRoom?.length ? (
|
||||||
<Row
|
<Row
|
||||||
label={`${intl.formatMessage(
|
label={`${intl.formatMessage(
|
||||||
{
|
{
|
||||||
id: "{totalChildren, plural, one {# child} other {# children}}",
|
id: "{totalChildren, plural, one {# child} other {# children}}",
|
||||||
},
|
},
|
||||||
{ totalChildren: children.length }
|
{ totalChildren: childrenInRoom.length }
|
||||||
)}, ${intl.formatMessage(
|
)}, ${intl.formatMessage(
|
||||||
{
|
{
|
||||||
id: "{totalBreakfasts, plural, one {# breakfast} other {# breakfasts}}",
|
id: "{totalBreakfasts, plural, one {# breakfast} other {# breakfasts}}",
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export default function SummaryUI({
|
|||||||
|
|
||||||
// TODO: Update for Multiroom later
|
// TODO: Update for Multiroom later
|
||||||
const adults = booking.rooms[0].adults
|
const adults = booking.rooms[0].adults
|
||||||
const children = booking.rooms[0].children
|
const children = booking.rooms[0].childrenInRoom
|
||||||
|
|
||||||
const childrenBeds = children?.reduce(
|
const childrenBeds = children?.reduce(
|
||||||
(acc, value) => {
|
(acc, value) => {
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import {
|
|||||||
type TrackingSDKHotelInfo,
|
type TrackingSDKHotelInfo,
|
||||||
type TrackingSDKPageData,
|
type TrackingSDKPageData,
|
||||||
} from "@/types/components/tracking"
|
} from "@/types/components/tracking"
|
||||||
import type { Lang } from "@/constants/languages"
|
|
||||||
|
|
||||||
function isValidHotelData(hotel: NullableHotelData): hotel is HotelData {
|
function isValidHotelData(hotel: NullableHotelData): hotel is HotelData {
|
||||||
return hotel !== null && hotel !== undefined
|
return hotel !== null && hotel !== undefined
|
||||||
@@ -37,7 +36,7 @@ export async function SelectHotelMapContainer({
|
|||||||
selectHotelParams,
|
selectHotelParams,
|
||||||
adultsInRoom,
|
adultsInRoom,
|
||||||
childrenInRoom,
|
childrenInRoom,
|
||||||
child,
|
childrenInRoomString,
|
||||||
}: SelectHotelMapContainerProps) {
|
}: SelectHotelMapContainerProps) {
|
||||||
const lang = getLang()
|
const lang = getLang()
|
||||||
const googleMapId = env.GOOGLE_DYNAMIC_MAP_ID
|
const googleMapId = env.GOOGLE_DYNAMIC_MAP_ID
|
||||||
@@ -49,7 +48,7 @@ export async function SelectHotelMapContainer({
|
|||||||
roomStayStartDate: selectHotelParams.fromDate,
|
roomStayStartDate: selectHotelParams.fromDate,
|
||||||
roomStayEndDate: selectHotelParams.toDate,
|
roomStayEndDate: selectHotelParams.toDate,
|
||||||
adults: adultsInRoom,
|
adults: adultsInRoom,
|
||||||
children: childrenInRoom,
|
children: childrenInRoomString,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -83,9 +82,11 @@ export async function SelectHotelMapContainer({
|
|||||||
arrivalDate: format(arrivalDate, "yyyy-MM-dd"),
|
arrivalDate: format(arrivalDate, "yyyy-MM-dd"),
|
||||||
departureDate: format(departureDate, "yyyy-MM-dd"),
|
departureDate: format(departureDate, "yyyy-MM-dd"),
|
||||||
noOfAdults: adultsInRoom,
|
noOfAdults: adultsInRoom,
|
||||||
noOfChildren: child?.length,
|
noOfChildren: childrenInRoom?.length,
|
||||||
ageOfChildren: child?.map((c) => c.age).join(","),
|
ageOfChildren: childrenInRoom?.map((c) => c.age).join(","),
|
||||||
childBedPreference: child?.map((c) => ChildBedMapEnum[c.bed]).join("|"),
|
childBedPreference: childrenInRoom
|
||||||
|
?.map((c) => ChildBedMapEnum[c.bed])
|
||||||
|
.join("|"),
|
||||||
noOfRooms: 1, // // TODO: Handle multiple rooms
|
noOfRooms: 1, // // TODO: Handle multiple rooms
|
||||||
duration: differenceInCalendarDays(departureDate, arrivalDate),
|
duration: differenceInCalendarDays(departureDate, arrivalDate),
|
||||||
leadTime: differenceInCalendarDays(arrivalDate, new Date()),
|
leadTime: differenceInCalendarDays(arrivalDate, new Date()),
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ export default async function SelectHotel({
|
|||||||
const {
|
const {
|
||||||
selectHotelParams,
|
selectHotelParams,
|
||||||
adultsInRoom,
|
adultsInRoom,
|
||||||
|
childrenInRoomString,
|
||||||
childrenInRoom,
|
childrenInRoom,
|
||||||
childrenInRoomArray,
|
|
||||||
} = reservationParams
|
} = reservationParams
|
||||||
|
|
||||||
const intl = await getIntl()
|
const intl = await getIntl()
|
||||||
@@ -60,7 +60,7 @@ export default async function SelectHotel({
|
|||||||
roomStayStartDate: selectHotelParams.fromDate,
|
roomStayStartDate: selectHotelParams.fromDate,
|
||||||
roomStayEndDate: selectHotelParams.toDate,
|
roomStayEndDate: selectHotelParams.toDate,
|
||||||
adults: adultsInRoom,
|
adults: adultsInRoom,
|
||||||
children: childrenInRoom,
|
children: childrenInRoomString,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -118,9 +118,9 @@ export default async function SelectHotel({
|
|||||||
arrivalDate: format(arrivalDate, "yyyy-MM-dd"),
|
arrivalDate: format(arrivalDate, "yyyy-MM-dd"),
|
||||||
departureDate: format(departureDate, "yyyy-MM-dd"),
|
departureDate: format(departureDate, "yyyy-MM-dd"),
|
||||||
noOfAdults: adultsInRoom,
|
noOfAdults: adultsInRoom,
|
||||||
noOfChildren: childrenInRoomArray?.length,
|
noOfChildren: childrenInRoom?.length,
|
||||||
ageOfChildren: childrenInRoomArray?.map((c) => c.age).join(","),
|
ageOfChildren: childrenInRoom?.map((c) => c.age).join(","),
|
||||||
childBedPreference: childrenInRoomArray
|
childBedPreference: childrenInRoom
|
||||||
?.map((c) => ChildBedMapEnum[c.bed])
|
?.map((c) => ChildBedMapEnum[c.bed])
|
||||||
.join("|"),
|
.join("|"),
|
||||||
noOfRooms: 1, // // TODO: Handle multiple rooms
|
noOfRooms: 1, // // TODO: Handle multiple rooms
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ export type ChildBed = {
|
|||||||
value: number
|
value: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TGuestsRoom = Required<Pick<Room, "adults" | "children">>
|
export type TGuestsRoom = Required<Pick<Room, "adults" | "childrenInRoom">>
|
||||||
|
|
||||||
export type GuestsRoomPickerProps = {
|
export type GuestsRoomPickerProps = {
|
||||||
index: number
|
index: number
|
||||||
|
|||||||
@@ -68,6 +68,6 @@ export type SelectHotelMapContainerProps = {
|
|||||||
city: Location
|
city: Location
|
||||||
selectHotelParams: SelectHotelSearchParams
|
selectHotelParams: SelectHotelSearchParams
|
||||||
adultsInRoom: number
|
adultsInRoom: number
|
||||||
childrenInRoom: string | undefined
|
childrenInRoomString: string | undefined
|
||||||
child: Child[] | undefined
|
childrenInRoom: Child[] | undefined
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export interface SelectHotelProps {
|
|||||||
reservationParams: {
|
reservationParams: {
|
||||||
selectHotelParams: SelectHotelSearchParams
|
selectHotelParams: SelectHotelSearchParams
|
||||||
adultsInRoom: number
|
adultsInRoom: number
|
||||||
childrenInRoom: string | undefined
|
childrenInRoomString: string | undefined
|
||||||
childrenInRoomArray: Child[] | undefined
|
childrenInRoom: Child[] | undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ export interface SelectHotelSearchParams {
|
|||||||
city: string
|
city: string
|
||||||
fromDate: string
|
fromDate: string
|
||||||
toDate: string
|
toDate: string
|
||||||
rooms: Pick<Room, "adults" | "children">[]
|
rooms: Pick<Room, "adults" | "childrenInRoom">[]
|
||||||
[key: string]: string | string[] | Pick<Room, "adults" | "children">[]
|
[key: string]: string | string[] | Pick<Room, "adults" | "childrenInRoom">[]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export interface Room {
|
|||||||
roomTypeCode: string
|
roomTypeCode: string
|
||||||
rateCode: string
|
rateCode: string
|
||||||
counterRateCode: string
|
counterRateCode: string
|
||||||
children?: Child[]
|
childrenInRoom?: Child[]
|
||||||
packages?: RoomPackageCodeEnum[]
|
packages?: RoomPackageCodeEnum[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
18
utils/url.ts
18
utils/url.ts
@@ -26,7 +26,7 @@ const keyedSearchParams = new Map([
|
|||||||
["fromdate", "fromDate"],
|
["fromdate", "fromDate"],
|
||||||
["todate", "toDate"],
|
["todate", "toDate"],
|
||||||
["hotel", "hotelId"],
|
["hotel", "hotelId"],
|
||||||
["child", "children"],
|
["child", "childrenInRoom"],
|
||||||
])
|
])
|
||||||
|
|
||||||
export function getKeyFromSearchParam(key: string): string {
|
export function getKeyFromSearchParam(key: string): string {
|
||||||
@@ -71,19 +71,19 @@ export function convertSearchParamsToObj<T extends PartialRoom>(
|
|||||||
roomObject[index].adults = Number(value)
|
roomObject[index].adults = Number(value)
|
||||||
|
|
||||||
// Child is an array, so we need to handle it separately
|
// Child is an array, so we need to handle it separately
|
||||||
} else if (roomObjectKey === "children") {
|
} else if (roomObjectKey === "childrenInRoom") {
|
||||||
const childIndex = Number(keys[3])
|
const childIndex = Number(keys[3])
|
||||||
const childKey = keys[4] as keyof Child
|
const childKey = keys[4] as keyof Child
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!("children" in roomObject[index]) ||
|
!("childrenInRoom" in roomObject[index]) ||
|
||||||
!Array.isArray(roomObject[index].children)
|
!Array.isArray(roomObject[index].childrenInRoom)
|
||||||
) {
|
) {
|
||||||
roomObject[index].children = []
|
roomObject[index].childrenInRoom = []
|
||||||
}
|
}
|
||||||
|
|
||||||
roomObject[index].children![childIndex] = {
|
roomObject[index].childrenInRoom![childIndex] = {
|
||||||
...roomObject[index].children![childIndex],
|
...roomObject[index].childrenInRoom![childIndex],
|
||||||
[childKey]: Number(value),
|
[childKey]: Number(value),
|
||||||
}
|
}
|
||||||
} else if (roomObjectKey === "packages") {
|
} else if (roomObjectKey === "packages") {
|
||||||
@@ -115,8 +115,8 @@ export function convertObjToSearchParams<T>(
|
|||||||
item.adults.toString()
|
item.adults.toString()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (item?.children) {
|
if (item?.childrenInRoom) {
|
||||||
item.children.forEach((child, childIndex) => {
|
item.childrenInRoom.forEach((child, childIndex) => {
|
||||||
bookingSearchParams.set(
|
bookingSearchParams.set(
|
||||||
`room[${index}].child[${childIndex}].age`,
|
`room[${index}].child[${childIndex}].age`,
|
||||||
child.age.toString()
|
child.age.toString()
|
||||||
|
|||||||
Reference in New Issue
Block a user