Merged in fix/handle-single-ancillaries (pull request #3231)

Fix(STAY-128): Handle single ancillaries

* fix: refactor ancillaries flow

* fix: add logic to determine if an ancillary requires quantity

* fix: breakout ancillary description to its own component

* fix: cleanup

* fix: cleanup


Approved-by: Bianca Widstam
Approved-by: Erik Tiekstra
This commit is contained in:
Christel Westerberg
2025-11-28 15:02:45 +00:00
parent 4eee1cff64
commit 69f194f7bf
40 changed files with 1310 additions and 1197 deletions

View File

@@ -506,6 +506,16 @@ export const breakfastPackagesSchema = z
data.attributes.packages.filter((pkg) => pkg.code?.match(/^(BRF\d+)$/gm))
)
// Determine if ancillary requires quantity based on unit name. These ancillaries are special
// since they are 1 per booking, but we have no other way than string matching on unit name
// to determine this from the API at the moment.
function getRequiresQuantity(unitName?: string) {
return (unitName && unitName === "Late check-out") ||
unitName === "Early check-in"
? false
: true
}
export const ancillaryPackagesSchema = z
.object({
data: z.object({
@@ -537,6 +547,7 @@ export const ancillaryPackagesSchema = z
requiresDeliveryTime: item.requiresDeliveryTime,
translatedCategoryName: ancillary.categoryName,
internalCategoryName: ancillary.internalCategoryName,
requiresQuantity: getRequiresQuantity(item.unitName),
})),
}))
.filter((ancillary) => ancillary.ancillaryContent.length > 0)

View File

@@ -40,6 +40,7 @@ export const ancillaryContentSchema = z.object({
descriptions: z.object({ html: z.string() }),
images: z.array(imageWithoutMetaDataSchema),
requiresDeliveryTime: z.boolean(),
unitName: z.string().optional(),
})
export const packageSchema = z.object({