fix/SW-902-update-response-city-availability (pull request #917)

Fix/SW-902 update response city availability

* fix(SW-902): update response for API changes

* fix(SW-902): add total row for pricePerStay

* fix(SW-902): fix optional requestedPrice

* fix(SW-902): fix bookingCode output

* feat(SW-903): fix sorting


Approved-by: Pontus Dreij
Approved-by: Niclas Edenvin
This commit is contained in:
Bianca Widstam
2024-11-18 15:08:12 +00:00
committed by Joakim Jäderberg
parent e078c59ac1
commit d49e301634
27 changed files with 217 additions and 227 deletions

View File

@@ -491,22 +491,6 @@ const occupancySchema = z.object({
children: z.array(childrenSchema),
})
const bestPricePerStaySchema = z.object({
currency: z.string(),
// TODO: remove optional when API is ready
regularAmount: z.string().optional(),
// TODO: remove optional when API is ready
memberAmount: z.string().optional(),
})
const bestPricePerNightSchema = z.object({
currency: z.string(),
// TODO: remove optional when API is ready
regularAmount: z.string().optional(),
// TODO: remove optional when API is ready
memberAmount: z.string().optional(),
})
const linksSchema = z.object({
links: z.array(
z.object({
@@ -516,30 +500,6 @@ const linksSchema = z.object({
),
})
const hotelsAvailabilitySchema = z.object({
data: z.array(
z.object({
attributes: z.object({
checkInDate: z.string(),
checkOutDate: z.string(),
occupancy: occupancySchema.optional(),
status: z.string(),
hotelId: z.number(),
ratePlanSet: z.string().optional(),
bestPricePerStay: bestPricePerStaySchema.optional(),
bestPricePerNight: bestPricePerNightSchema.optional(),
}),
relationships: linksSchema.optional(),
type: z.string().optional(),
})
),
})
export const getHotelsAvailabilitySchema = hotelsAvailabilitySchema
export type HotelsAvailability = z.infer<typeof hotelsAvailabilitySchema>
export type HotelsAvailabilityPrices =
HotelsAvailability["data"][number]["attributes"]["bestPricePerNight"]
export const priceSchema = z.object({
pricePerNight: z.coerce.number(),
pricePerStay: z.coerce.number(),
@@ -550,7 +510,7 @@ export const productTypePriceSchema = z.object({
rateCode: z.string(),
rateType: z.string().optional(),
localPrice: priceSchema,
requestedPrice: priceSchema,
requestedPrice: priceSchema.optional(),
})
const productSchema = z.object({
@@ -560,6 +520,34 @@ const productSchema = z.object({
}),
})
const hotelsAvailabilitySchema = z.object({
data: z.array(
z.object({
attributes: z.object({
checkInDate: z.string(),
checkOutDate: z.string(),
occupancy: occupancySchema,
status: z.string(),
hotelId: z.number(),
productType: z
.object({
public: productTypePriceSchema.optional(),
member: productTypePriceSchema.optional(),
})
.optional(),
}),
relationships: linksSchema.optional(),
type: z.string().optional(),
})
),
})
export const getHotelsAvailabilitySchema = hotelsAvailabilitySchema
export type HotelsAvailability = z.infer<typeof hotelsAvailabilitySchema>
export type ProductType =
HotelsAvailability["data"][number]["attributes"]["productType"]
export type ProductTypePrices = z.infer<typeof productTypePriceSchema>
const roomConfigurationSchema = z.object({
status: z.string(),
roomTypeCode: z.string(),