sub-task/ SW-695 Prefill Guests data in booking widget

This commit is contained in:
Hrishikesh Vaipurkar
2024-10-25 08:50:23 +02:00
parent 31da31b72d
commit 05d353e224
18 changed files with 342 additions and 182 deletions
@@ -7,6 +7,7 @@ import { dt } from "@/lib/dt"
import DatePicker from "@/components/DatePicker"
import GuestsRoomsPickerForm from "@/components/GuestsRoomsPicker"
import GuestsRoomsProvider from "@/components/GuestsRoomsPicker/Provider/GuestsRoomsProvider"
import { SearchIcon } from "@/components/Icons"
import Button from "@/components/TempDesignSystem/Button"
import Caption from "@/components/TempDesignSystem/Text/Caption"
@@ -29,6 +30,8 @@ export default function FormContent({
const nights = dt(selectedDate.toDate).diff(dt(selectedDate.fromDate), "days")
const selectedGuests = useWatch({ name: "rooms" })
return (
<>
<div className={styles.input}>
@@ -51,7 +54,9 @@ export default function FormContent({
{rooms}
</Caption>
</label>
<GuestsRoomsPickerForm />
<GuestsRoomsProvider selectedGuests={selectedGuests}>
<GuestsRoomsPickerForm name="rooms" />
</GuestsRoomsProvider>
</div>
</div>
<div className={styles.voucherContainer}>
+1 -1
View File
@@ -42,7 +42,7 @@ export default function Form({ locations, type }: BookingWidgetFormProps) {
data.rooms.forEach((room, index) => {
bookingWidgetParams.set(`room[${index}].adults`, room.adults.toString())
room.children.forEach((child, childIndex) => {
room.child.forEach((child, childIndex) => {
bookingWidgetParams.set(
`room[${index}].child[${childIndex}].age`,
child.age.toString()
+1 -1
View File
@@ -4,7 +4,7 @@ import type { Location } from "@/types/trpc/routers/hotel/locations"
export const guestRoomSchema = z.object({
adults: z.number().default(1),
children: z.array(
child: z.array(
z.object({
age: z.number().nonnegative(),
bed: z.number(),