feat: add no breakfast message to price details modal and to conf page receipt
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
|||||||
} from "@/server/routers/hotels/schemas/packages"
|
} from "@/server/routers/hotels/schemas/packages"
|
||||||
|
|
||||||
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
|
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
|
||||||
|
import type { BreakfastPackage } from "@/types/components/hotelReservation/breakfast"
|
||||||
import { BreakfastPackageEnum } from "@/types/enums/breakfast"
|
import { BreakfastPackageEnum } from "@/types/enums/breakfast"
|
||||||
import { PackageTypeEnum } from "@/types/enums/packages"
|
import { PackageTypeEnum } from "@/types/enums/packages"
|
||||||
import type { Package } from "@/types/requests/packages"
|
import type { Package } from "@/types/requests/packages"
|
||||||
@@ -47,24 +48,37 @@ export function mapToPrice(rooms: (Room | null)[], nights: number) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const breakfastPackage = breakfastPackageSchema.safeParse({
|
let breakfast:
|
||||||
code: room.breakfast?.code,
|
| false
|
||||||
description: room.breakfast?.description,
|
| undefined
|
||||||
localPrice: {
|
| Omit<BreakfastPackage, "requestedPrice">
|
||||||
currency: room.breakfast?.currency,
|
if (room.breakfast) {
|
||||||
price: room.breakfast?.unitPrice,
|
const breakfastPackage = breakfastPackageSchema.safeParse({
|
||||||
totalPrice: room.breakfast?.totalPrice,
|
code: room.breakfast?.code,
|
||||||
},
|
description: room.breakfast?.description,
|
||||||
packageType:
|
localPrice: {
|
||||||
room.breakfast?.code === BreakfastPackageEnum.REGULAR_BREAKFAST
|
currency: room.breakfast?.currency,
|
||||||
? PackageTypeEnum.BreakfastAdult
|
price: room.breakfast?.unitPrice,
|
||||||
: "",
|
totalPrice: room.breakfast?.totalPrice,
|
||||||
requestedPrice: {
|
},
|
||||||
currency: room.breakfast?.currency,
|
packageType:
|
||||||
price: room.breakfast?.unitPrice,
|
room.breakfast?.code === BreakfastPackageEnum.REGULAR_BREAKFAST
|
||||||
totalPrice: room.breakfast?.totalPrice,
|
? PackageTypeEnum.BreakfastAdult
|
||||||
},
|
: "",
|
||||||
})
|
requestedPrice: {
|
||||||
|
currency: room.breakfast?.currency,
|
||||||
|
price: room.breakfast?.unitPrice,
|
||||||
|
totalPrice: room.breakfast?.totalPrice,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if (breakfastPackage.success) {
|
||||||
|
breakfast = breakfastPackage.data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!room.breakfastIncluded && !breakfast) {
|
||||||
|
breakfast = false
|
||||||
|
}
|
||||||
|
|
||||||
const packages = room.roomFeatures
|
const packages = room.roomFeatures
|
||||||
?.map((featPkg) => {
|
?.map((featPkg) => {
|
||||||
@@ -97,7 +111,7 @@ export function mapToPrice(rooms: (Room | null)[], nights: number) {
|
|||||||
description: room.bedDescription,
|
description: room.bedDescription,
|
||||||
roomTypeCode: room.roomTypeCode || "",
|
roomTypeCode: room.roomTypeCode || "",
|
||||||
},
|
},
|
||||||
breakfast: breakfastPackage.success ? breakfastPackage.data : undefined,
|
breakfast,
|
||||||
breakfastIncluded: room.rateDefinition.breakfastIncluded,
|
breakfastIncluded: room.rateDefinition.breakfastIncluded,
|
||||||
childrenInRoom: room.childrenAges?.map((age) => ({
|
childrenInRoom: room.childrenAges?.map((age) => ({
|
||||||
age,
|
age,
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
.entry {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.textDefault {
|
||||||
|
color: var(--Text-Default);
|
||||||
|
}
|
||||||
|
|
||||||
|
.textSecondary {
|
||||||
|
color: var(--Text-Secondary);
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
"use client"
|
||||||
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
|
|
||||||
|
import { formatPrice } from "@/utils/numberFormatting"
|
||||||
|
|
||||||
|
import styles from "./breakfast.module.css"
|
||||||
|
|
||||||
|
import type { PackageSchema } from "@/types/trpc/routers/booking/confirmation"
|
||||||
|
|
||||||
|
interface BreakfastProps {
|
||||||
|
breakfast: PackageSchema | false | undefined
|
||||||
|
breakfastIncluded: boolean
|
||||||
|
guests: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Breakfast({
|
||||||
|
breakfast,
|
||||||
|
breakfastIncluded,
|
||||||
|
guests,
|
||||||
|
}: BreakfastProps) {
|
||||||
|
const intl = useIntl()
|
||||||
|
|
||||||
|
const breakfastBuffet = intl.formatMessage({
|
||||||
|
defaultMessage: "Breakfast buffet",
|
||||||
|
})
|
||||||
|
|
||||||
|
if (breakfastIncluded || breakfast) {
|
||||||
|
const price = breakfast
|
||||||
|
? formatPrice(intl, breakfast.totalPrice, breakfast.currency)
|
||||||
|
: intl.formatMessage({ defaultMessage: "Included" })
|
||||||
|
return (
|
||||||
|
<div className={styles.entry}>
|
||||||
|
<div>
|
||||||
|
<Typography variant="Body/Paragraph/mdRegular">
|
||||||
|
<p className={styles.textDefault}>{breakfastBuffet}</p>
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="Body/Supporting text (caption)/smRegular">
|
||||||
|
<p className={styles.textSecondary}>{guests}</p>
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
<Typography variant="Body/Paragraph/mdRegular">
|
||||||
|
<p className={styles.textDefault}>{price}</p>
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (breakfast === false) {
|
||||||
|
const noBreakfast = intl.formatMessage({ defaultMessage: "No breakfast" })
|
||||||
|
return (
|
||||||
|
<div className={styles.entry}>
|
||||||
|
<Typography variant="Body/Paragraph/mdRegular">
|
||||||
|
<p className={styles.textDefault}>{breakfastBuffet}</p>
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="Body/Paragraph/mdRegular">
|
||||||
|
<p className={styles.textDefault}>{noBreakfast}</p>
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import Button from "@/components/TempDesignSystem/Button"
|
|||||||
import Link from "@/components/TempDesignSystem/Link"
|
import Link from "@/components/TempDesignSystem/Link"
|
||||||
import { formatPrice } from "@/utils/numberFormatting"
|
import { formatPrice } from "@/utils/numberFormatting"
|
||||||
|
|
||||||
|
import Breakfast from "./Breakfast"
|
||||||
import RoomSkeletonLoader from "./RoomSkeletonLoader"
|
import RoomSkeletonLoader from "./RoomSkeletonLoader"
|
||||||
|
|
||||||
import styles from "./room.module.css"
|
import styles from "./room.module.css"
|
||||||
@@ -34,8 +35,7 @@ export default function ReceiptRoom({
|
|||||||
if (!room) {
|
if (!room) {
|
||||||
return <RoomSkeletonLoader />
|
return <RoomSkeletonLoader />
|
||||||
}
|
}
|
||||||
const breakfastIncluded =
|
|
||||||
room.breakfastIncluded || room.rateDefinition.breakfastIncluded
|
|
||||||
const childBedCrib = room.childBedPreferences.find(
|
const childBedCrib = room.childBedPreferences.find(
|
||||||
(c) => c.bedType === ChildBedTypeEnum.Crib
|
(c) => c.bedType === ChildBedTypeEnum.Crib
|
||||||
)
|
)
|
||||||
@@ -63,6 +63,8 @@ export default function ReceiptRoom({
|
|||||||
guestsParts.push(childrenMsg)
|
guestsParts.push(childrenMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const guests = guestsParts.join(", ")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<article className={styles.room}>
|
<article className={styles.room}>
|
||||||
<header className={styles.roomHeader}>
|
<header className={styles.roomHeader}>
|
||||||
@@ -83,9 +85,7 @@ export default function ReceiptRoom({
|
|||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
<Typography variant="Body/Paragraph/mdRegular">
|
<Typography variant="Body/Paragraph/mdRegular">
|
||||||
<p className={styles.uiTextMediumContrast}>
|
<p className={styles.uiTextMediumContrast}>{guests}</p>
|
||||||
{guestsParts.join(", ")}
|
|
||||||
</p>
|
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="Body/Paragraph/mdRegular">
|
<Typography variant="Body/Paragraph/mdRegular">
|
||||||
<p className={styles.uiTextMediumContrast}>
|
<p className={styles.uiTextMediumContrast}>
|
||||||
@@ -226,37 +226,11 @@ export default function ReceiptRoom({
|
|||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{room.breakfast || breakfastIncluded ? (
|
<Breakfast
|
||||||
<div className={styles.entry}>
|
breakfast={room.breakfast}
|
||||||
<Typography variant="Body/Paragraph/mdRegular">
|
breakfastIncluded={room.breakfastIncluded}
|
||||||
<p>
|
guests={guests}
|
||||||
{intl.formatMessage({
|
/>
|
||||||
defaultMessage: "Breakfast buffet",
|
|
||||||
})}
|
|
||||||
</p>
|
|
||||||
</Typography>
|
|
||||||
{breakfastIncluded ? (
|
|
||||||
<Typography variant="Body/Paragraph/mdRegular">
|
|
||||||
<p className={styles.red}>
|
|
||||||
{intl.formatMessage({
|
|
||||||
defaultMessage: "Included",
|
|
||||||
})}
|
|
||||||
</p>
|
|
||||||
</Typography>
|
|
||||||
) : null}
|
|
||||||
{room.breakfast && !breakfastIncluded ? (
|
|
||||||
<Typography variant="Body/Paragraph/mdRegular">
|
|
||||||
<p className={styles.uiTextHighContrast}>
|
|
||||||
{formatPrice(
|
|
||||||
intl,
|
|
||||||
room.breakfast.totalPrice,
|
|
||||||
room.breakfast.currency
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
</Typography>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
</article>
|
</article>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,19 +5,30 @@ import type { IntlShape } from "react-intl"
|
|||||||
import type { BookingConfirmationRoom } from "@/types/components/hotelReservation/bookingConfirmation/bookingConfirmation"
|
import type { BookingConfirmationRoom } from "@/types/components/hotelReservation/bookingConfirmation/bookingConfirmation"
|
||||||
import { BreakfastPackageEnum } from "@/types/enums/breakfast"
|
import { BreakfastPackageEnum } from "@/types/enums/breakfast"
|
||||||
import { CurrencyEnum } from "@/types/enums/currency"
|
import { CurrencyEnum } from "@/types/enums/currency"
|
||||||
import type { BookingConfirmationSchema } from "@/types/trpc/routers/booking/confirmation"
|
import type {
|
||||||
|
BookingConfirmationSchema,
|
||||||
|
PackageSchema,
|
||||||
|
} from "@/types/trpc/routers/booking/confirmation"
|
||||||
|
|
||||||
export function mapRoomState(
|
export function mapRoomState(
|
||||||
booking: BookingConfirmationSchema,
|
booking: BookingConfirmationSchema,
|
||||||
room: BookingConfirmationRoom,
|
room: BookingConfirmationRoom,
|
||||||
intl: IntlShape
|
intl: IntlShape
|
||||||
) {
|
) {
|
||||||
const breakfast = booking.packages.find(
|
const breakfastPackage = booking.packages.find(
|
||||||
(pkg) => pkg.code === BreakfastPackageEnum.REGULAR_BREAKFAST
|
(pkg) => pkg.code === BreakfastPackageEnum.REGULAR_BREAKFAST
|
||||||
)
|
)
|
||||||
const breakfastIncluded = booking.packages.some(
|
const breakfastIncluded =
|
||||||
(pkg) => pkg.code === BreakfastPackageEnum.FREE_MEMBER_BREAKFAST
|
booking.packages.some(
|
||||||
)
|
(pkg) => pkg.code === BreakfastPackageEnum.FREE_MEMBER_BREAKFAST
|
||||||
|
) || booking.rateDefinition.breakfastIncluded
|
||||||
|
|
||||||
|
let breakfast: false | undefined | PackageSchema
|
||||||
|
if (breakfastPackage) {
|
||||||
|
breakfast = breakfastPackage
|
||||||
|
} else if (!breakfastIncluded) {
|
||||||
|
breakfast = false
|
||||||
|
}
|
||||||
|
|
||||||
let formattedRoomCost = formatPrice(
|
let formattedRoomCost = formatPrice(
|
||||||
intl,
|
intl,
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
.entry {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--Spacing-x-half);
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.textDefault {
|
||||||
|
color: var(--Text-Default);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uiTextMediumContrast {
|
||||||
|
color: var(--UI-Text-Medium-contrast);
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
"use client"
|
||||||
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
|
|
||||||
|
import { formatPrice } from "@/utils/numberFormatting"
|
||||||
|
|
||||||
|
import styles from "./breakfast.module.css"
|
||||||
|
|
||||||
|
import type { BreakfastPackage } from "@/types/components/hotelReservation/breakfast"
|
||||||
|
|
||||||
|
interface BreakfastProps {
|
||||||
|
adults: number
|
||||||
|
breakfast: BreakfastPackage | false | undefined
|
||||||
|
breakfastIncluded: boolean
|
||||||
|
guests: string
|
||||||
|
nights: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Breakfast({
|
||||||
|
adults,
|
||||||
|
breakfast,
|
||||||
|
breakfastIncluded,
|
||||||
|
guests,
|
||||||
|
nights,
|
||||||
|
}: BreakfastProps) {
|
||||||
|
const intl = useIntl()
|
||||||
|
|
||||||
|
const breakfastBuffet = intl.formatMessage({
|
||||||
|
defaultMessage: "Breakfast buffet",
|
||||||
|
})
|
||||||
|
|
||||||
|
if (breakfastIncluded || breakfast) {
|
||||||
|
const price = breakfast
|
||||||
|
? formatPrice(
|
||||||
|
intl,
|
||||||
|
breakfast.localPrice.price * adults * nights,
|
||||||
|
breakfast.localPrice.currency
|
||||||
|
)
|
||||||
|
: intl.formatMessage({ defaultMessage: "Included" })
|
||||||
|
return (
|
||||||
|
<div className={styles.entry}>
|
||||||
|
<div>
|
||||||
|
<Typography variant="Body/Paragraph/mdRegular">
|
||||||
|
<p className={styles.textDefault}>{breakfastBuffet}</p>
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="Body/Supporting text (caption)/smRegular">
|
||||||
|
<p className={styles.uiTextMediumContrast}>{guests}</p>
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
<Typography variant="Body/Paragraph/mdRegular">
|
||||||
|
<p className={styles.textDefault}>{price}</p>
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (breakfast === false) {
|
||||||
|
const noBreakfast = intl.formatMessage({ defaultMessage: "No breakfast" })
|
||||||
|
return (
|
||||||
|
<div className={styles.entry}>
|
||||||
|
<Typography variant="Body/Paragraph/mdRegular">
|
||||||
|
<p className={styles.textDefault}>{breakfastBuffet}</p>
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="Body/Paragraph/mdRegular">
|
||||||
|
<p className={styles.textDefault}>{noBreakfast}</p>
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
|||||||
import useLang from "@/hooks/useLang"
|
import useLang from "@/hooks/useLang"
|
||||||
import { formatPrice } from "@/utils/numberFormatting"
|
import { formatPrice } from "@/utils/numberFormatting"
|
||||||
|
|
||||||
|
import Breakfast from "./Breakfast"
|
||||||
import { mapToPrice } from "./mapToPrice"
|
import { mapToPrice } from "./mapToPrice"
|
||||||
|
|
||||||
import styles from "./ui.module.css"
|
import styles from "./ui.module.css"
|
||||||
@@ -185,6 +186,8 @@ export default function SummaryUI({
|
|||||||
guestsParts.push(childrenMsg)
|
guestsParts.push(childrenMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const guests = guestsParts.join(", ")
|
||||||
|
|
||||||
const hideBedCurrency = notDisplayableCurrencies.includes(
|
const hideBedCurrency = notDisplayableCurrencies.includes(
|
||||||
room.roomPrice.perStay.local.currency
|
room.roomPrice.perStay.local.currency
|
||||||
)
|
)
|
||||||
@@ -233,9 +236,7 @@ export default function SummaryUI({
|
|||||||
)}
|
)}
|
||||||
</Body>
|
</Body>
|
||||||
</div>
|
</div>
|
||||||
<Caption color="uiTextMediumContrast">
|
<Caption color="uiTextMediumContrast">{guests}</Caption>
|
||||||
{guestsParts.join(", ")}
|
|
||||||
</Caption>
|
|
||||||
<Caption color="uiTextMediumContrast">
|
<Caption color="uiTextMediumContrast">
|
||||||
{room.cancellationText}
|
{room.cancellationText}
|
||||||
</Caption>
|
</Caption>
|
||||||
@@ -371,82 +372,13 @@ export default function SummaryUI({
|
|||||||
</Body>
|
</Body>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{room.breakfastIncluded ? (
|
<Breakfast
|
||||||
<div className={styles.entry}>
|
adults={room.adults}
|
||||||
<Body color="uiTextHighContrast">
|
breakfast={room.breakfast}
|
||||||
{intl.formatMessage({
|
breakfastIncluded={room.breakfastIncluded}
|
||||||
defaultMessage: "Breakfast buffet",
|
guests={guests}
|
||||||
})}
|
nights={nights}
|
||||||
</Body>
|
/>
|
||||||
<Body color="red">
|
|
||||||
{intl.formatMessage({
|
|
||||||
defaultMessage: "Included",
|
|
||||||
})}
|
|
||||||
</Body>
|
|
||||||
</div>
|
|
||||||
) : room.breakfast === false ? (
|
|
||||||
<div className={styles.entry}>
|
|
||||||
<Body color="uiTextHighContrast">
|
|
||||||
{intl.formatMessage({
|
|
||||||
defaultMessage: "No breakfast",
|
|
||||||
})}
|
|
||||||
</Body>
|
|
||||||
<Body color="uiTextHighContrast">
|
|
||||||
{formatPrice(
|
|
||||||
intl,
|
|
||||||
0,
|
|
||||||
room.roomPrice.perStay.local.currency
|
|
||||||
)}
|
|
||||||
</Body>
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
{room.breakfast ? (
|
|
||||||
<div>
|
|
||||||
<Body color="uiTextHighContrast">
|
|
||||||
{intl.formatMessage({
|
|
||||||
defaultMessage: "Breakfast buffet",
|
|
||||||
})}
|
|
||||||
</Body>
|
|
||||||
<div className={styles.entry}>
|
|
||||||
<Caption color="uiTextMediumContrast">
|
|
||||||
{intl.formatMessage(
|
|
||||||
{
|
|
||||||
defaultMessage:
|
|
||||||
"{totalAdults, plural, one {# adult} other {# adults}}",
|
|
||||||
},
|
|
||||||
{ totalAdults: adults }
|
|
||||||
)}
|
|
||||||
</Caption>
|
|
||||||
<Body color="uiTextHighContrast">
|
|
||||||
{formatPrice(
|
|
||||||
intl,
|
|
||||||
room.breakfast.localPrice.price * adults * nights,
|
|
||||||
room.breakfast.localPrice.currency
|
|
||||||
)}
|
|
||||||
</Body>
|
|
||||||
</div>
|
|
||||||
{childrenInRoom?.length ? (
|
|
||||||
<div className={styles.entry}>
|
|
||||||
<Caption color="uiTextMediumContrast">
|
|
||||||
{intl.formatMessage(
|
|
||||||
{
|
|
||||||
defaultMessage:
|
|
||||||
"{totalChildren, plural, one {# child} other {# children}}",
|
|
||||||
},
|
|
||||||
{ totalChildren: childrenInRoom.length }
|
|
||||||
)}
|
|
||||||
</Caption>
|
|
||||||
<Body color="uiTextHighContrast">
|
|
||||||
{formatPrice(
|
|
||||||
intl,
|
|
||||||
0,
|
|
||||||
room.breakfast.localPrice.currency
|
|
||||||
)}
|
|
||||||
</Body>
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
</div>
|
</div>
|
||||||
<Divider color="primaryLightSubtle" />
|
<Divider color="primaryLightSubtle" />
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ export default function Steps({ closeModal }: ChangeDatesStepsProps) {
|
|||||||
setDates({ fromDate, toDate })
|
setDates({ fromDate, toDate })
|
||||||
|
|
||||||
const pkgsSum = sumPackages(packages)
|
const pkgsSum = sumPackages(packages)
|
||||||
const extraPrice = pkgsSum.price + (breakfast?.localPrice.totalPrice || 0)
|
const extraPrice =
|
||||||
|
pkgsSum.price + ((breakfast && breakfast.localPrice.totalPrice) || 0)
|
||||||
if (isLoggedIn && "member" in data.product && data.product.member) {
|
if (isLoggedIn && "member" in data.product && data.product.member) {
|
||||||
const { currency, pricePerStay } = data.product.member.localPrice
|
const { currency, pricePerStay } = data.product.member.localPrice
|
||||||
setNewPrice(formatPrice(intl, pricePerStay + extraPrice, currency))
|
setNewPrice(formatPrice(intl, pricePerStay + extraPrice, currency))
|
||||||
|
|||||||
@@ -40,19 +40,21 @@ export function mapRoomDetails({
|
|||||||
)
|
)
|
||||||
|
|
||||||
// We don't get `requestedPrice` in packages
|
// We don't get `requestedPrice` in packages
|
||||||
const breakfast: Omit<BreakfastPackage, "requestedPrice"> | null =
|
let breakfast: Omit<BreakfastPackage, "requestedPrice"> | undefined | false
|
||||||
breakfastPackageAdults
|
if (breakfastPackageAdults) {
|
||||||
? {
|
breakfast = {
|
||||||
code: breakfastPackageAdults.code,
|
code: breakfastPackageAdults.code,
|
||||||
description: breakfastPackageAdults.description,
|
description: breakfastPackageAdults.description,
|
||||||
localPrice: {
|
localPrice: {
|
||||||
currency: breakfastPackageAdults.currency,
|
currency: breakfastPackageAdults.currency,
|
||||||
price: breakfastPackageAdults.unitPrice,
|
price: breakfastPackageAdults.unitPrice,
|
||||||
totalPrice: breakfastPackageAdults.totalPrice,
|
totalPrice: breakfastPackageAdults.totalPrice,
|
||||||
},
|
},
|
||||||
packageType: PackageTypeEnum.BreakfastAdult,
|
packageType: PackageTypeEnum.BreakfastAdult,
|
||||||
}
|
}
|
||||||
: null
|
} else if (!booking.rateDefinition.breakfastIncluded) {
|
||||||
|
breakfast = false
|
||||||
|
}
|
||||||
|
|
||||||
const validBreakfastPackagesChildren: string[] = [
|
const validBreakfastPackagesChildren: string[] = [
|
||||||
BreakfastPackageEnum.ANCILLARY_CHILD_PAYING_BREAKFAST,
|
BreakfastPackageEnum.ANCILLARY_CHILD_PAYING_BREAKFAST,
|
||||||
@@ -62,17 +64,17 @@ export function mapRoomDetails({
|
|||||||
)
|
)
|
||||||
// We don't get `requestedPrice` in packages
|
// We don't get `requestedPrice` in packages
|
||||||
const breakfastChildren: Omit<BreakfastPackage, "requestedPrice"> | null =
|
const breakfastChildren: Omit<BreakfastPackage, "requestedPrice"> | null =
|
||||||
breakfastPackageChildren
|
(breakfastPackageChildren && !booking.rateDefinition.breakfastIncluded)
|
||||||
? {
|
? {
|
||||||
code: breakfastPackageChildren.code,
|
code: breakfastPackageChildren.code,
|
||||||
description: breakfastPackageChildren.description,
|
description: breakfastPackageChildren.description,
|
||||||
localPrice: {
|
localPrice: {
|
||||||
currency: breakfastPackageChildren.currency,
|
currency: breakfastPackageChildren.currency,
|
||||||
price: breakfastPackageChildren.unitPrice,
|
price: breakfastPackageChildren.unitPrice,
|
||||||
totalPrice: breakfastPackageChildren.totalPrice,
|
totalPrice: breakfastPackageChildren.totalPrice,
|
||||||
},
|
},
|
||||||
packageType: PackageTypeEnum.BreakfastChildren,
|
packageType: PackageTypeEnum.BreakfastChildren,
|
||||||
}
|
}
|
||||||
: null
|
: null
|
||||||
|
|
||||||
const isCancelled = booking.reservationStatus === BookingStatusEnum.Cancelled
|
const isCancelled = booking.reservationStatus === BookingStatusEnum.Cancelled
|
||||||
|
|||||||
@@ -31,8 +31,99 @@ export default function Breakfast({
|
|||||||
}: BreakfastProps) {
|
}: BreakfastProps) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
|
|
||||||
|
const breakfastBuffet = intl.formatMessage({
|
||||||
|
defaultMessage: "Breakfast buffet",
|
||||||
|
})
|
||||||
|
|
||||||
|
const adultsMsg = intl.formatMessage(
|
||||||
|
{
|
||||||
|
defaultMessage:
|
||||||
|
"Breakfast ({totalAdults, plural, one {# adult} other {# adults}}) x {totalBreakfasts}",
|
||||||
|
},
|
||||||
|
{ totalAdults: adults, totalBreakfasts: nights }
|
||||||
|
)
|
||||||
|
|
||||||
|
let kidsMsg = ""
|
||||||
|
if (childrenInRoom?.length) {
|
||||||
|
kidsMsg = intl.formatMessage(
|
||||||
|
{
|
||||||
|
defaultMessage:
|
||||||
|
"Breakfast ({totalChildren, plural, one {# child} other {# children}}) x {totalBreakfasts}",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
totalChildren: childrenInRoom.length,
|
||||||
|
totalBreakfasts: nights,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (breakfastIncluded) {
|
if (breakfastIncluded) {
|
||||||
const included = intl.formatMessage({ defaultMessage: "Included" })
|
const included = intl.formatMessage({ defaultMessage: "Included" })
|
||||||
|
return (
|
||||||
|
<Tbody>
|
||||||
|
<RegularRow label={adultsMsg} value={included} />
|
||||||
|
{childrenInRoom?.length ? (
|
||||||
|
<RegularRow label={kidsMsg} value={included} />
|
||||||
|
) : null}
|
||||||
|
<BoldRow
|
||||||
|
label={breakfastBuffet}
|
||||||
|
value={formatPrice(intl, 0, currency)}
|
||||||
|
/>
|
||||||
|
</Tbody>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (breakfast) {
|
||||||
|
const adultPricePerNight = breakfast.localPrice.price * adults
|
||||||
|
const breakfastAdultsPricePerNight = formatPrice(
|
||||||
|
intl,
|
||||||
|
adultPricePerNight,
|
||||||
|
breakfast.localPrice.currency
|
||||||
|
)
|
||||||
|
|
||||||
|
const { payingChildren, freeChildren } = childrenInRoom.reduce(
|
||||||
|
(total, child) => {
|
||||||
|
if (child.age >= 4) {
|
||||||
|
total.payingChildren = total.payingChildren + 1
|
||||||
|
} else {
|
||||||
|
total.freeChildren = total.freeChildren + 1
|
||||||
|
}
|
||||||
|
return total
|
||||||
|
},
|
||||||
|
{ payingChildren: 0, freeChildren: 0 }
|
||||||
|
)
|
||||||
|
|
||||||
|
const childrenPrice = breakfastChildren?.localPrice.price || 0
|
||||||
|
const childrenPricePerNight = childrenPrice * payingChildren
|
||||||
|
|
||||||
|
const childCurrency =
|
||||||
|
breakfastChildren?.localPrice.currency ?? breakfast.localPrice.currency
|
||||||
|
|
||||||
|
const breakfastChildrenPricePerNight = formatPrice(
|
||||||
|
intl,
|
||||||
|
childrenPricePerNight,
|
||||||
|
childCurrency
|
||||||
|
)
|
||||||
|
|
||||||
|
const totalAdultsPrice = adultPricePerNight * nights
|
||||||
|
const totalChildrenPrice = childrenPricePerNight * nights
|
||||||
|
const breakfastTotalPrice = formatPrice(
|
||||||
|
intl,
|
||||||
|
totalAdultsPrice + totalChildrenPrice,
|
||||||
|
breakfast.localPrice.currency
|
||||||
|
)
|
||||||
|
|
||||||
|
const freeChildrenMsg = intl.formatMessage(
|
||||||
|
{
|
||||||
|
defaultMessage:
|
||||||
|
"Breakfast ({totalChildren, plural, one {# child} other {# children}}) x {totalBreakfasts}",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
totalChildren: freeChildren,
|
||||||
|
totalBreakfasts: nights,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tbody border>
|
<Tbody border>
|
||||||
<RegularRow
|
<RegularRow
|
||||||
@@ -43,9 +134,30 @@ export default function Breakfast({
|
|||||||
},
|
},
|
||||||
{ totalAdults: adults, totalBreakfasts: nights }
|
{ totalAdults: adults, totalBreakfasts: nights }
|
||||||
)}
|
)}
|
||||||
value={included}
|
value={breakfastAdultsPricePerNight}
|
||||||
/>
|
/>
|
||||||
{childrenInRoom?.length ? (
|
{breakfastChildren ? (
|
||||||
|
<RegularRow
|
||||||
|
label={intl.formatMessage(
|
||||||
|
{
|
||||||
|
defaultMessage:
|
||||||
|
"Breakfast ({totalChildren, plural, one {# child} other {# children}}) x {totalBreakfasts}",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
totalChildren: payingChildren,
|
||||||
|
totalBreakfasts: nights,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
value={breakfastChildrenPricePerNight}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
{breakfastChildren && freeChildren ? (
|
||||||
|
<RegularRow
|
||||||
|
label={`${freeChildrenMsg} (0-3)`}
|
||||||
|
value={formatPrice(intl, 0, breakfast.localPrice.currency)}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
{childrenInRoom?.length && !breakfastChildren ? (
|
||||||
<RegularRow
|
<RegularRow
|
||||||
label={intl.formatMessage(
|
label={intl.formatMessage(
|
||||||
{
|
{
|
||||||
@@ -57,123 +169,24 @@ export default function Breakfast({
|
|||||||
totalBreakfasts: nights,
|
totalBreakfasts: nights,
|
||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
value={included}
|
value={formatPrice(intl, 0, breakfast.localPrice.currency)}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
<BoldRow
|
<BoldRow label={breakfastBuffet} value={breakfastTotalPrice} />
|
||||||
label={intl.formatMessage({ defaultMessage: "Breakfast charge" })}
|
|
||||||
value={formatPrice(intl, 0, currency)}
|
|
||||||
/>
|
|
||||||
</Tbody>
|
</Tbody>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!breakfast) {
|
if (breakfast === false) {
|
||||||
return null
|
const noBreakfast = intl.formatMessage({
|
||||||
|
defaultMessage: "No breakfast",
|
||||||
|
})
|
||||||
|
return (
|
||||||
|
<Tbody>
|
||||||
|
<BoldRow label={breakfastBuffet} value={noBreakfast} />
|
||||||
|
</Tbody>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const adultPricePerNight = breakfast.localPrice.price * adults
|
return null
|
||||||
const breakfastAdultsPricePerNight = formatPrice(
|
|
||||||
intl,
|
|
||||||
adultPricePerNight,
|
|
||||||
breakfast.localPrice.currency
|
|
||||||
)
|
|
||||||
|
|
||||||
const { payingChildren, freeChildren } = childrenInRoom.reduce(
|
|
||||||
(total, child) => {
|
|
||||||
if (child.age >= 4) {
|
|
||||||
total.payingChildren = total.payingChildren + 1
|
|
||||||
} else {
|
|
||||||
total.freeChildren = total.freeChildren + 1
|
|
||||||
}
|
|
||||||
return total
|
|
||||||
},
|
|
||||||
{ payingChildren: 0, freeChildren: 0 }
|
|
||||||
)
|
|
||||||
|
|
||||||
const childrenPrice = breakfastChildren?.localPrice.price || 0
|
|
||||||
const childrenPricePerNight = childrenPrice * payingChildren
|
|
||||||
|
|
||||||
const childCurrency =
|
|
||||||
breakfastChildren?.localPrice.currency ?? breakfast.localPrice.currency
|
|
||||||
|
|
||||||
const breakfastChildrenPricePerNight = formatPrice(
|
|
||||||
intl,
|
|
||||||
childrenPricePerNight,
|
|
||||||
childCurrency
|
|
||||||
)
|
|
||||||
|
|
||||||
const totalAdultsPrice = adultPricePerNight * nights
|
|
||||||
const totalChildrenPrice = childrenPricePerNight * nights
|
|
||||||
const breakfastTotalPrice = formatPrice(
|
|
||||||
intl,
|
|
||||||
totalAdultsPrice + totalChildrenPrice,
|
|
||||||
breakfast.localPrice.currency
|
|
||||||
)
|
|
||||||
|
|
||||||
const freeChildrenMsg = intl.formatMessage(
|
|
||||||
{
|
|
||||||
defaultMessage:
|
|
||||||
"Breakfast ({totalChildren, plural, one {# child} other {# children}}) x {totalBreakfasts}",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
totalChildren: freeChildren,
|
|
||||||
totalBreakfasts: nights,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Tbody border>
|
|
||||||
<RegularRow
|
|
||||||
label={intl.formatMessage(
|
|
||||||
{
|
|
||||||
defaultMessage:
|
|
||||||
"Breakfast ({totalAdults, plural, one {# adult} other {# adults}}) x {totalBreakfasts}",
|
|
||||||
},
|
|
||||||
{ totalAdults: adults, totalBreakfasts: nights }
|
|
||||||
)}
|
|
||||||
value={breakfastAdultsPricePerNight}
|
|
||||||
/>
|
|
||||||
{breakfastChildren ? (
|
|
||||||
<RegularRow
|
|
||||||
label={intl.formatMessage(
|
|
||||||
{
|
|
||||||
defaultMessage:
|
|
||||||
"Breakfast ({totalChildren, plural, one {# child} other {# children}}) x {totalBreakfasts}",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
totalChildren: payingChildren,
|
|
||||||
totalBreakfasts: nights,
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
value={breakfastChildrenPricePerNight}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
{breakfastChildren && freeChildren ? (
|
|
||||||
<RegularRow
|
|
||||||
label={`${freeChildrenMsg} (0-3)`}
|
|
||||||
value={formatPrice(intl, 0, breakfast.localPrice.currency)}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
{childrenInRoom?.length && !breakfastChildren ? (
|
|
||||||
<RegularRow
|
|
||||||
label={intl.formatMessage(
|
|
||||||
{
|
|
||||||
defaultMessage:
|
|
||||||
"Breakfast ({totalChildren, plural, one {# child} other {# children}}) x {totalBreakfasts}",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
totalChildren: childrenInRoom.length,
|
|
||||||
totalBreakfasts: nights,
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
value={formatPrice(intl, 0, breakfast.localPrice.currency)}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
<BoldRow
|
|
||||||
label={intl.formatMessage({ defaultMessage: "Breakfast charge" })}
|
|
||||||
value={breakfastTotalPrice}
|
|
||||||
/>
|
|
||||||
</Tbody>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export type Room = Pick<
|
|||||||
| "vouchers"
|
| "vouchers"
|
||||||
> & {
|
> & {
|
||||||
bedType: BedTypeSchema
|
bedType: BedTypeSchema
|
||||||
breakfast: Omit<BreakfastPackage, "requestedPrice"> | null
|
breakfast: Omit<BreakfastPackage, "requestedPrice"> | false | undefined
|
||||||
childrenInRoom: Child[]
|
childrenInRoom: Child[]
|
||||||
isCancelled: boolean
|
isCancelled: boolean
|
||||||
packages: Packages | null
|
packages: Packages | null
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export interface Room {
|
|||||||
adults: number
|
adults: number
|
||||||
bedDescription: string
|
bedDescription: string
|
||||||
bookingCode: string | null
|
bookingCode: string | null
|
||||||
breakfast?: PackageSchema
|
breakfast: PackageSchema | false | undefined
|
||||||
breakfastIncluded: boolean
|
breakfastIncluded: boolean
|
||||||
cheques: number
|
cheques: number
|
||||||
childBedPreferences: ChildBedPreference[]
|
childBedPreferences: ChildBedPreference[]
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export type Room = Pick<
|
|||||||
| "vouchers"
|
| "vouchers"
|
||||||
> & {
|
> & {
|
||||||
bedType: BedTypeSchema
|
bedType: BedTypeSchema
|
||||||
breakfast: Omit<BreakfastPackage, "requestedPrice"> | null
|
breakfast: Omit<BreakfastPackage, "requestedPrice"> | undefined | false
|
||||||
breakfastChildren: Omit<BreakfastPackage, "requestedPrice"> | null
|
breakfastChildren: Omit<BreakfastPackage, "requestedPrice"> | null
|
||||||
childrenAsString: string
|
childrenAsString: string
|
||||||
childrenInRoom: Child[]
|
childrenInRoom: Child[]
|
||||||
|
|||||||
Reference in New Issue
Block a user