Merged in feat/SW-822-handle-breakfast-included (pull request #1138)
Feat/SW-822 handle breakfast included * feat(SW-822): Added flag for breakfast included and hide breakfast step if included * fix: check if window is defined to avoid error during SSR * fix: remove return if rate definition is not found because its expected if input is undefined Approved-by: Christel Westerberg Approved-by: Arvid Norlin
This commit is contained in:
@@ -126,7 +126,7 @@ export default async function StepPage({
|
||||
return notFound()
|
||||
}
|
||||
|
||||
const mustBeGuaranteed = roomAvailability?.mustBeGuaranteed ?? false
|
||||
const { mustBeGuaranteed, breakfastIncluded } = roomAvailability
|
||||
|
||||
const paymentGuarantee = intl.formatMessage({
|
||||
id: "Payment Guarantee",
|
||||
@@ -191,13 +191,18 @@ export default async function StepPage({
|
||||
isMember: !!user,
|
||||
rateDetails: roomAvailability.rateDetails,
|
||||
roomType: roomAvailability.selectedRoom.roomType,
|
||||
breakfastIncluded,
|
||||
}
|
||||
|
||||
const showBreakfastStep = Boolean(
|
||||
breakfastPackages?.length && !breakfastIncluded
|
||||
)
|
||||
|
||||
return (
|
||||
<EnterDetailsProvider
|
||||
bedTypes={roomAvailability.bedTypes}
|
||||
booking={booking}
|
||||
breakfastPackages={breakfastPackages}
|
||||
showBreakfastStep={showBreakfastStep}
|
||||
packages={packages}
|
||||
roomRate={{
|
||||
memberRate: roomAvailability.memberRate,
|
||||
@@ -231,13 +236,13 @@ export default async function StepPage({
|
||||
</SectionAccordion>
|
||||
) : null}
|
||||
|
||||
{breakfastPackages?.length ? (
|
||||
{showBreakfastStep ? (
|
||||
<SectionAccordion
|
||||
header={intl.formatMessage({ id: "Food options" })}
|
||||
label={intl.formatMessage({ id: "Select breakfast options" })}
|
||||
step={StepEnum.breakfast}
|
||||
>
|
||||
<Breakfast packages={breakfastPackages} />
|
||||
<Breakfast packages={breakfastPackages!} />
|
||||
</SectionAccordion>
|
||||
) : null}
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ export default function SummaryUI({
|
||||
isMember,
|
||||
rateDetails,
|
||||
roomType,
|
||||
breakfastIncluded,
|
||||
}: SummaryProps) {
|
||||
const intl = useIntl()
|
||||
const lang = useLang()
|
||||
@@ -242,7 +243,13 @@ export default function SummaryUI({
|
||||
</Body>
|
||||
</div>
|
||||
) : null}
|
||||
{breakfast === false ? (
|
||||
{breakfastIncluded ? (
|
||||
<div className={styles.entry}>
|
||||
<Body color="uiTextHighContrast">
|
||||
{intl.formatMessage({ id: "Breakfast included" })}
|
||||
</Body>
|
||||
</div>
|
||||
) : breakfast === false ? (
|
||||
<div className={styles.entry}>
|
||||
<Body color="uiTextHighContrast">
|
||||
{intl.formatMessage({ id: "No breakfast" })}
|
||||
|
||||
@@ -25,7 +25,7 @@ import type { DetailsState, InitialState } from "@/types/stores/enter-details"
|
||||
export default function EnterDetailsProvider({
|
||||
bedTypes,
|
||||
booking,
|
||||
breakfastPackages,
|
||||
showBreakfastStep,
|
||||
children,
|
||||
packages,
|
||||
roomRate,
|
||||
@@ -44,7 +44,7 @@ export default function EnterDetailsProvider({
|
||||
roomTypeCode: bedTypes[0].value,
|
||||
}
|
||||
}
|
||||
if (!breakfastPackages?.length) {
|
||||
if (!showBreakfastStep) {
|
||||
initialData.breakfast = false
|
||||
}
|
||||
|
||||
|
||||
@@ -554,14 +554,20 @@ export const hotelQueryRouter = router({
|
||||
(room) => room.roomType === selectedRoom?.roomType
|
||||
)
|
||||
if (!selectedRoom) {
|
||||
selectedRoomAvailabilityFailCounter.add(1, {
|
||||
hotelId,
|
||||
roomStayStartDate,
|
||||
roomStayEndDate,
|
||||
adults,
|
||||
children,
|
||||
bookingCode,
|
||||
error_type: "not_found",
|
||||
error: `Couldn't find selected room with input: ${roomTypeCode}`,
|
||||
})
|
||||
console.error("No matching room found")
|
||||
return null
|
||||
}
|
||||
|
||||
const rateDetails = validateAvailabilityData.data.rateDefinitions.find(
|
||||
(rateDef) => rateDef.rateCode === rateCode
|
||||
)?.generalTerms
|
||||
|
||||
const rateTypes = selectedRoom.products.find(
|
||||
(rate) =>
|
||||
rate.productType.public?.rateCode === rateCode ||
|
||||
@@ -569,20 +575,25 @@ export const hotelQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!rateTypes) {
|
||||
selectedRoomAvailabilityFailCounter.add(1, {
|
||||
hotelId,
|
||||
roomStayStartDate,
|
||||
roomStayEndDate,
|
||||
adults,
|
||||
children,
|
||||
bookingCode,
|
||||
error_type: "not_found",
|
||||
error: `Couldn't find rateTypes for selected room: ${JSON.stringify(selectedRoom)}`,
|
||||
})
|
||||
console.error("No matching rate found")
|
||||
return null
|
||||
}
|
||||
const rates = rateTypes.productType
|
||||
|
||||
const mustBeGuaranteed =
|
||||
validateAvailabilityData.data.rateDefinitions.filter(
|
||||
(rate) => rate.rateCode === rateCode
|
||||
)[0].mustBeGuaranteed
|
||||
|
||||
const cancellationText =
|
||||
const rateDefinition =
|
||||
validateAvailabilityData.data.rateDefinitions.find(
|
||||
(rate) => rate.rateCode === rateCode
|
||||
)?.cancellationText ?? ""
|
||||
)
|
||||
|
||||
const bedTypes = availableRoomsInCategory
|
||||
.map((availRoom) => {
|
||||
@@ -623,9 +634,10 @@ export const hotelQueryRouter = router({
|
||||
|
||||
return {
|
||||
selectedRoom,
|
||||
rateDetails,
|
||||
mustBeGuaranteed,
|
||||
cancellationText,
|
||||
rateDetails: rateDefinition?.generalTerms,
|
||||
cancellationText: rateDefinition?.cancellationText ?? "",
|
||||
mustBeGuaranteed: !!rateDefinition?.mustBeGuaranteed,
|
||||
breakfastIncluded: !!rateDefinition?.breakfastIncluded,
|
||||
memberRate: rates?.member,
|
||||
publicRate: rates.public,
|
||||
bedTypes,
|
||||
|
||||
@@ -15,4 +15,5 @@ export interface SummaryProps
|
||||
extends Pick<RoomAvailability, "cancellationText" | "rateDetails">,
|
||||
Pick<RoomAvailability["selectedRoom"], "roomType"> {
|
||||
isMember: boolean
|
||||
breakfastIncluded: boolean
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { Packages } from "../requests/packages"
|
||||
export interface DetailsProviderProps extends React.PropsWithChildren {
|
||||
booking: BookingData
|
||||
bedTypes: BedTypeSelection[]
|
||||
breakfastPackages: BreakfastPackage[] | null
|
||||
showBreakfastStep: boolean
|
||||
packages: Packages | null
|
||||
roomRate: Pick<RoomAvailability, "memberRate" | "publicRate">
|
||||
searchParamsStr: string
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import type { TrackingPosition, TrackingSDKData } from "@/types/components/tracking"
|
||||
import type {
|
||||
TrackingPosition,
|
||||
TrackingSDKData,
|
||||
} from "@/types/components/tracking"
|
||||
|
||||
export function trackClick(name: string) {
|
||||
pushToDataLayer({
|
||||
@@ -60,7 +63,7 @@ export function createSDKPageObject(
|
||||
|
||||
return {
|
||||
...trackingData,
|
||||
domain: window.location.host,
|
||||
domain: typeof window !== "undefined" ? window.location.host : "",
|
||||
pageName: pageName,
|
||||
siteSections: siteSections,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user