Merged in fix/STAY-131-hide-ancillaries (pull request #3299)

fix: fix logic for identifying single use ancillaries

* fix: fix logic for identifying single use ancillaries

* fix: filter out empty categories of ancillaries


Approved-by: Erik Tiekstra
This commit is contained in:
Christel Westerberg
2025-12-05 12:25:12 +00:00
parent 3bd23bf56e
commit 001000a56d
7 changed files with 125 additions and 73 deletions

View File

@@ -444,14 +444,28 @@ 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
enum SingleUseAncillaryIds {
EarlyCheckIn = "0060",
LateCheckOut = "0061",
EarlyCheckinPilot = "0060999",
LateCheckoutPilot = "0061999",
}
// Determine if ancillary requires quantity based on ID. These ancillaries are special since they
// are 1 per booking. The agreement is to use the same last digits in the ID for both early check-in
// and late check-out ancillaries in order to identify them here regardless of language or market.
// During the Pilot phase, the IDs are different but the same logic applies.
function getRequiresQuantity(id: string) {
const code = id.split("_").pop()
if (code) {
return Object.values(SingleUseAncillaryIds).includes(
code as SingleUseAncillaryIds
)
? false
: true
}
return true
}
export const ancillaryPackagesSchema = z
@@ -485,7 +499,7 @@ export const ancillaryPackagesSchema = z
requiresDeliveryTime: item.requiresDeliveryTime,
translatedCategoryName: ancillary.categoryName,
internalCategoryName: ancillary.internalCategoryName,
requiresQuantity: getRequiresQuantity(item.unitName),
requiresQuantity: getRequiresQuantity(item.id),
})),
}))
.filter((ancillary) => ancillary.ancillaryContent.length > 0)

View File

@@ -66,6 +66,6 @@ export const breakfastPackageSchema = z.object({
export const ancillaryPackageSchema = z.object({
categoryName: z.string(),
internalCategoryName: z.string(),
internalCategoryName: z.string().optional(),
ancillaryContent: z.array(ancillaryContentSchema),
})