Merged in fix/add-multinight-breakfast (pull request #1705)
The number of breakfasts and total sums weren’t correctly calculated. This fixes that. Also changes display logic of when the ancillaries sections are shown Approved-by: Bianca Widstam
This commit is contained in:
@@ -46,8 +46,12 @@ export default function PriceDetails({
|
||||
}
|
||||
|
||||
const totalPrice = isBreakfast
|
||||
? breakfastData!.priceAdult * breakfastData!.nrOfAdults +
|
||||
breakfastData!.priceChild * breakfastData!.nrOfPayingChildren
|
||||
? breakfastData!.priceAdult *
|
||||
breakfastData!.nrOfAdults *
|
||||
breakfastData!.nrOfNights +
|
||||
breakfastData!.priceChild *
|
||||
breakfastData!.nrOfPayingChildren *
|
||||
breakfastData!.nrOfNights
|
||||
: quantityWithCard && selectedAncillary
|
||||
? selectedAncillary.price.total * quantityWithCard
|
||||
: null
|
||||
@@ -73,7 +77,7 @@ export default function PriceDetails({
|
||||
title: `${selectedAncillary.title} / ${intl.formatMessage({ id: "Adult" })}`,
|
||||
totalPrice: breakfastData.priceAdult,
|
||||
currency: breakfastData.currency,
|
||||
quantityWithCard: breakfastData.nrOfAdults,
|
||||
quantityWithCard: breakfastData.nrOfAdults * breakfastData.nrOfNights,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -82,7 +86,8 @@ export default function PriceDetails({
|
||||
title: `${selectedAncillary.title} / ${intl.formatMessage({ id: "Children" })} 4-12`,
|
||||
totalPrice: breakfastData.priceChild,
|
||||
currency: breakfastData.currency,
|
||||
quantityWithCard: breakfastData.nrOfPayingChildren,
|
||||
quantityWithCard:
|
||||
breakfastData.nrOfPayingChildren * breakfastData.nrOfNights,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -91,7 +96,8 @@ export default function PriceDetails({
|
||||
title: `${selectedAncillary.title} / ${intl.formatMessage({ id: "Children under {age}" }, { age: 4 })}`,
|
||||
totalPrice: 0,
|
||||
currency: breakfastData.currency,
|
||||
quantityWithCard: breakfastData.nrOfFreeChildren,
|
||||
quantityWithCard:
|
||||
breakfastData.nrOfFreeChildren * breakfastData.nrOfNights,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||
import { PaymentMethodEnum } from "@/constants/booking"
|
||||
import { guaranteeCallback } from "@/constants/routes/hotelReservation"
|
||||
import { env } from "@/env/client"
|
||||
import { dt } from "@/lib/dt"
|
||||
import { trpc } from "@/lib/trpc/client"
|
||||
import {
|
||||
AncillaryStepEnum,
|
||||
@@ -300,11 +301,16 @@ export default function AddAncillaryFlowModal({
|
||||
isBreakfast,
|
||||
packages,
|
||||
booking.adults,
|
||||
booking.childrenAges
|
||||
booking.childrenAges,
|
||||
dt(booking.checkOutDate)
|
||||
.startOf("day")
|
||||
.diff(dt(booking.checkInDate).startOf("day"), "days")
|
||||
)
|
||||
)
|
||||
}, [
|
||||
booking.adults,
|
||||
booking.checkInDate,
|
||||
booking.checkOutDate,
|
||||
booking.childrenAges,
|
||||
isBreakfast,
|
||||
packages,
|
||||
@@ -471,7 +477,8 @@ function calculateBreakfastData(
|
||||
isBreakfast: boolean,
|
||||
packages: Packages | null,
|
||||
nrOfAdults: number,
|
||||
childrenAges: number[]
|
||||
childrenAges: number[],
|
||||
nrOfNights: number
|
||||
): BreakfastData | null {
|
||||
if (!isBreakfast) {
|
||||
return null
|
||||
@@ -503,6 +510,7 @@ function calculateBreakfastData(
|
||||
nrOfAdults,
|
||||
nrOfPayingChildren,
|
||||
nrOfFreeChildren,
|
||||
nrOfNights,
|
||||
priceAdult,
|
||||
priceChild,
|
||||
currency,
|
||||
|
||||
@@ -168,35 +168,42 @@ export function Ancillaries({
|
||||
return (
|
||||
<AddAncillaryProvider booking={booking} ancillaries={allAncillaries}>
|
||||
<div className={styles.container}>
|
||||
<div className={styles.title}>
|
||||
<Title as="h5">
|
||||
{intl.formatMessage({ id: "Upgrade your stay" })}
|
||||
</Title>
|
||||
<ViewAllAncillaries />
|
||||
</div>
|
||||
{uniqueAncillaries.length > 0 && (
|
||||
<>
|
||||
<div className={styles.title}>
|
||||
<Title as="h5">
|
||||
{intl.formatMessage({ id: "Upgrade your stay" })}
|
||||
</Title>
|
||||
<ViewAllAncillaries />
|
||||
</div>
|
||||
|
||||
<div className={styles.ancillaries}>
|
||||
{uniqueAncillaries.slice(0, 4).map((ancillary) => (
|
||||
<WrappedAncillaryCard ancillary={ancillary} key={ancillary.id} />
|
||||
))}
|
||||
</div>
|
||||
<div className={styles.ancillaries}>
|
||||
{uniqueAncillaries.slice(0, 4).map((ancillary) => (
|
||||
<WrappedAncillaryCard
|
||||
ancillary={ancillary}
|
||||
key={ancillary.id}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className={styles.mobileAncillaries}>
|
||||
<Carousel>
|
||||
<Carousel.Content>
|
||||
{uniqueAncillaries.map((ancillary) => {
|
||||
return (
|
||||
<Carousel.Item key={ancillary.id}>
|
||||
<WrappedAncillaryCard ancillary={ancillary} />
|
||||
</Carousel.Item>
|
||||
)
|
||||
})}
|
||||
</Carousel.Content>
|
||||
<Carousel.Previous />
|
||||
<Carousel.Next />
|
||||
<Carousel.Dots />
|
||||
</Carousel>
|
||||
</div>
|
||||
<div className={styles.mobileAncillaries}>
|
||||
<Carousel>
|
||||
<Carousel.Content>
|
||||
{uniqueAncillaries.map((ancillary) => {
|
||||
return (
|
||||
<Carousel.Item key={ancillary.id}>
|
||||
<WrappedAncillaryCard ancillary={ancillary} />
|
||||
</Carousel.Item>
|
||||
)
|
||||
})}
|
||||
</Carousel.Content>
|
||||
<Carousel.Previous />
|
||||
<Carousel.Next />
|
||||
<Carousel.Dots />
|
||||
</Carousel>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
<AddedAncillaries booking={booking} ancillaries={uniqueAncillaries} />
|
||||
<AncillaryFlowModalWrapper>
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
nullableStringValidator,
|
||||
} from "@/utils/zod/stringValidator"
|
||||
|
||||
import { BreakfastPackageEnum } from "@/types/enums/breakfast"
|
||||
import { CurrencyEnum } from "@/types/enums/currency"
|
||||
|
||||
const guestSchema = z.object({
|
||||
@@ -250,11 +251,15 @@ export const bookingConfirmationSchema = z
|
||||
packages: data.attributes.packages.filter((p) => p.type !== "Ancillary"),
|
||||
ancillaries: data.attributes.packages.filter((p) => p.type === "Ancillary"),
|
||||
extraBedTypes: data.attributes.childBedPreferences,
|
||||
showAncillaries: !!(
|
||||
data.links.addAncillary ||
|
||||
data.attributes.packages.some((p) => p.type === "Ancillary") ||
|
||||
data.attributes.reservationStatus === BookingStatusEnum.Cancelled
|
||||
),
|
||||
showAncillaries:
|
||||
!!(
|
||||
data.links.addAncillary ||
|
||||
data.attributes.packages.some(
|
||||
(p) =>
|
||||
p.type === "Ancillary" ||
|
||||
p.code === BreakfastPackageEnum.ANCILLARY_REGULAR_BREAKFAST
|
||||
)
|
||||
) && data.attributes.reservationStatus !== BookingStatusEnum.Cancelled,
|
||||
isCancelable: !!data.links.cancel,
|
||||
isModifiable: !!data.links.modify,
|
||||
}))
|
||||
|
||||
@@ -34,6 +34,7 @@ export type BreakfastData = {
|
||||
nrOfAdults: number
|
||||
nrOfPayingChildren: number
|
||||
nrOfFreeChildren: number
|
||||
nrOfNights: number
|
||||
priceAdult: number
|
||||
priceChild: number
|
||||
currency: string
|
||||
|
||||
Reference in New Issue
Block a user