chore: Cleanup scandic-web * Remove unused files * Remove unused and add missing packages * Remove unused exports Approved-by: Linus Flood
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { BreakfastPackageEnum } from "@scandic-hotels/trpc/enums/breakfast"
|
|
|
|
function hasBreakfastPackageFromBookingFlow(
|
|
packages: {
|
|
code: string
|
|
}[]
|
|
) {
|
|
return packages.some(
|
|
(p) =>
|
|
p.code === BreakfastPackageEnum.REGULAR_BREAKFAST ||
|
|
p.code === BreakfastPackageEnum.FREE_MEMBER_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
|
|
)
|
|
}
|