fix: rename children to childrenInRoom

This commit is contained in:
Christel Westerberg
2025-01-14 12:25:17 +01:00
parent b2935114e3
commit bcae63e3fc
26 changed files with 104 additions and 91 deletions

View File

@@ -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],
})
}
})