fix: rename children to childrenInRoom
This commit is contained in:
@@ -6,7 +6,7 @@ import type { Location } from "@/types/trpc/routers/hotel/locations"
|
||||
export const guestRoomSchema = z
|
||||
.object({
|
||||
adults: z.number().default(1),
|
||||
children: z
|
||||
childrenInRoom: z
|
||||
.array(
|
||||
z.object({
|
||||
age: z.number().min(0, "Age is required"),
|
||||
@@ -16,11 +16,11 @@ export const guestRoomSchema = z
|
||||
.default([]),
|
||||
})
|
||||
.superRefine((value, ctx) => {
|
||||
const childrenInAdultsBed = value.children.filter(
|
||||
const childrenInAdultsBed = value.childrenInRoom.filter(
|
||||
(c) => c.bed === ChildBedMapEnum.IN_ADULTS_BED
|
||||
)
|
||||
if (value.adults < childrenInAdultsBed.length) {
|
||||
const lastAdultBedIndex = value.children
|
||||
const lastAdultBedIndex = value.childrenInRoom
|
||||
.map((c) => c.bed)
|
||||
.lastIndexOf(ChildBedMapEnum.IN_ADULTS_BED)
|
||||
|
||||
@@ -28,7 +28,7 @@ export const guestRoomSchema = z
|
||||
code: z.ZodIssueCode.custom,
|
||||
message:
|
||||
"You cannot have more children in adults bed than adults in the room",
|
||||
path: ["child", lastAdultBedIndex],
|
||||
path: ["childrenInRoom", lastAdultBedIndex],
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user