Merged in feat/sw-1839-show-added-breakfast (pull request #1673)
Feat/sw-1839 show added breakfast * Fix wrong space character * Change to correct CSS variable * Show added breakfast ancillary in the "My add-ons" section * Show breakfast info in room card * Show breakfast in price details table * Format price Approved-by: Pontus Dreij
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { BreakfastPackageEnum } from "@/types/enums/breakfast"
|
||||
|
||||
export function hasBreakfastPackage(
|
||||
export function hasBreakfastPackageFromBookingFlow(
|
||||
packages: {
|
||||
code: string
|
||||
}[]
|
||||
@@ -12,3 +12,41 @@ export function hasBreakfastPackage(
|
||||
p.code === BreakfastPackageEnum.SPECIAL_PACKAGE_BREAKFAST
|
||||
)
|
||||
}
|
||||
|
||||
export function getBreakfastPackagesFromBookingFlow<T extends { code: string }>(
|
||||
packages: T[]
|
||||
): T[] | undefined {
|
||||
// Since `FREE_CHILD_BREAKFAST` has the same code when breakfast is added
|
||||
// in the booking flow and as ancillary we can't just do a simple filter on the codes.
|
||||
// So we shortcircuit if there are no booking flow specific packages.
|
||||
if (!packages || !hasBreakfastPackageFromBookingFlow(packages)) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return packages.filter(
|
||||
(p) =>
|
||||
p.code === BreakfastPackageEnum.REGULAR_BREAKFAST ||
|
||||
p.code === BreakfastPackageEnum.FREE_MEMBER_BREAKFAST ||
|
||||
p.code === BreakfastPackageEnum.CHILD_PAYING_BREAKFAST ||
|
||||
p.code === BreakfastPackageEnum.FREE_CHILD_BREAKFAST ||
|
||||
p.code === BreakfastPackageEnum.SPECIAL_PACKAGE_BREAKFAST
|
||||
)
|
||||
}
|
||||
|
||||
export function getBreakfastPackagesFromAncillaryFlow<
|
||||
T extends { code: string },
|
||||
>(packages: T[]): T[] | undefined {
|
||||
// Since `FREE_CHILD_BREAKFAST` has the same code when breakfast is added
|
||||
// in the booking flow and as ancillary we can't just do a simple filter on the codes.
|
||||
// So we shortcircuit if there are any booking flow specific packages.
|
||||
if (!packages || hasBreakfastPackageFromBookingFlow(packages)) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return packages.filter(
|
||||
(p) =>
|
||||
p.code === BreakfastPackageEnum.ANCILLARY_REGULAR_BREAKFAST ||
|
||||
p.code === BreakfastPackageEnum.ANCILLARY_CHILD_PAYING_BREAKFAST ||
|
||||
p.code === BreakfastPackageEnum.FREE_CHILD_BREAKFAST
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user