Merged in fix/SW-2462-room-availability-error (pull request #1920)
Fix/SW-2462 room availability error * fix: added toast error when availability fails and you get redirect to select-rate * fix: added support for showing alert when availability error happens * fix: rename PaymentAlert -> BookingAlert Approved-by: Erik Tiekstra
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { notFound, redirect } from "next/navigation"
|
||||
import { Suspense } from "react"
|
||||
|
||||
import { BookingErrorCodeEnum } from "@/constants/booking"
|
||||
import { selectRate } from "@/constants/routes/hotelReservation"
|
||||
import {
|
||||
getBreakfastPackages,
|
||||
@@ -16,8 +17,6 @@ import RoomOne from "@/components/HotelReservation/EnterDetails/Room/One"
|
||||
import DesktopSummary from "@/components/HotelReservation/EnterDetails/Summary/Desktop"
|
||||
import MobileSummary from "@/components/HotelReservation/EnterDetails/Summary/Mobile"
|
||||
import EnterDetailsTrackingWrapper from "@/components/HotelReservation/EnterDetails/Tracking"
|
||||
import Alert from "@/components/TempDesignSystem/Alert"
|
||||
import { getIntl } from "@/i18n"
|
||||
import RoomProvider from "@/providers/Details/RoomProvider"
|
||||
import EnterDetailsProvider from "@/providers/EnterDetailsProvider"
|
||||
import { convertSearchParamsToObj } from "@/utils/url"
|
||||
@@ -25,7 +24,6 @@ import { convertSearchParamsToObj } from "@/utils/url"
|
||||
import styles from "./page.module.css"
|
||||
|
||||
import type { SelectRateSearchParams } from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||
import { AlertTypeEnum } from "@/types/enums/alert"
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
import type { Room } from "@/types/providers/details/room"
|
||||
|
||||
@@ -71,6 +69,7 @@ export default async function DetailsPage({
|
||||
// (possibly also add an error case to url?)
|
||||
// -------------------------------------------------------
|
||||
// redirect back to select-rate if availability call fails
|
||||
selectRoomParams.set("errorCode", BookingErrorCodeEnum.AvailabilityError)
|
||||
redirect(`${selectRate(lang)}?${selectRoomParams.toString()}`)
|
||||
}
|
||||
|
||||
@@ -94,12 +93,9 @@ export default async function DetailsPage({
|
||||
hotel.merchantInformationData.alternatePaymentOptions = []
|
||||
}
|
||||
|
||||
const intl = await getIntl()
|
||||
|
||||
const firstRoom = rooms[0]
|
||||
const multirooms = rooms.slice(1)
|
||||
|
||||
const isRoomNotAvailable = rooms.some((room) => !room.isAvailable)
|
||||
return (
|
||||
<EnterDetailsProvider
|
||||
booking={booking}
|
||||
@@ -112,26 +108,6 @@ export default async function DetailsPage({
|
||||
<main>
|
||||
<HotelHeader hotelData={hotelData} />
|
||||
<div className={styles.container}>
|
||||
{isRoomNotAvailable && (
|
||||
<Alert
|
||||
type={AlertTypeEnum.Alarm}
|
||||
variant="inline"
|
||||
heading={intl.formatMessage({
|
||||
defaultMessage: "Room sold out",
|
||||
})}
|
||||
text={intl.formatMessage({
|
||||
defaultMessage:
|
||||
"Unfortunately, one of the rooms you selected is sold out. Please choose another room to proceed.",
|
||||
})}
|
||||
link={{
|
||||
title: intl.formatMessage({
|
||||
defaultMessage: "Change room",
|
||||
}),
|
||||
url: `${selectRate(lang)}?${selectRoomParams.toString()}`,
|
||||
keepSearchParams: true,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<div className={styles.content}>
|
||||
<RoomProvider idx={0} room={firstRoom}>
|
||||
<RoomOne user={user} />
|
||||
|
||||
Reference in New Issue
Block a user