feat(SW-415): Normalize roomSchema

This commit is contained in:
Pontus Dreij
2024-10-10 14:10:03 +02:00
parent 9d106713a0
commit c69b473de1
4 changed files with 45 additions and 32 deletions

View File

@@ -425,26 +425,39 @@ const roomFacilitiesSchema = z.object({
sortOrder: z.number(),
})
export const roomSchema = z.object({
attributes: z.object({
name: z.string(),
sortOrder: z.number(),
content: roomContentSchema,
roomTypes: z.array(roomTypesSchema),
roomFacilities: z.array(roomFacilitiesSchema),
occupancy: z.object({
total: z.number(),
adults: z.number(),
children: z.number(),
export const roomSchema = z
.object({
attributes: z.object({
name: z.string(),
sortOrder: z.number(),
content: roomContentSchema,
roomTypes: z.array(roomTypesSchema),
roomFacilities: z.array(roomFacilitiesSchema),
occupancy: z.object({
total: z.number(),
adults: z.number(),
children: z.number(),
}),
roomSize: z.object({
min: z.number(),
max: z.number(),
}),
}),
roomSize: z.object({
min: z.number(),
max: z.number(),
}),
}),
id: z.string(),
type: z.enum(["roomcategories"]),
})
id: z.string(),
type: z.enum(["roomcategories"]),
})
.transform((data) => {
return {
descriptions: data.attributes.content.texts.descriptions,
id: data.id,
images: data.attributes.content.images,
name: data.attributes.name,
occupancy: data.attributes.occupancy,
roomSize: data.attributes.roomSize,
sortOrder: data.attributes.sortOrder,
type: data.type,
}
})
const merchantInformationSchema = z.object({
webMerchantId: z.string(),