fix: correct membershipFailedError logic

This commit is contained in:
Arvid Norlin
2025-05-05 16:16:17 +02:00
committed by Michael Zetterberg
parent 7213bde423
commit afda7f851a
4 changed files with 25 additions and 55 deletions

View File

@@ -5,6 +5,7 @@ import { getBookingConfirmation } from "@/lib/trpc/memoizedRequests"
import BookingConfirmation from "@/components/HotelReservation/BookingConfirmation"
import type { LangParams, PageArgs } from "@/types/params"
import { MEMBERSHIP_FAILED_ERROR } from "@/constants/booking"
export default async function BookingConfirmationPage({
searchParams,
@@ -17,5 +18,13 @@ export default async function BookingConfirmationPage({
void getBookingConfirmation(refId)
return <BookingConfirmation refId={refId} />
const membershipFailedError =
searchParams.errorCode === MEMBERSHIP_FAILED_ERROR
return (
<BookingConfirmation
refId={refId}
membershipFailedError={membershipFailedError}
/>
)
}

View File

@@ -1,52 +0,0 @@
"use client"
import { useSearchParams } from "next/navigation"
import { useIntl } from "react-intl"
import { MEMBERSHIP_FAILED_ERROR } from "@/constants/booking"
import Alert from "@/components/TempDesignSystem/Alert"
import type { BookingConfirmationAlertsProps } from "@/types/components/hotelReservation/bookingConfirmation/bookingConfirmation"
import { AlertTypeEnum } from "@/types/enums/alert"
export default function Alerts({ booking }: BookingConfirmationAlertsProps) {
const intl = useIntl()
const searchParams = useSearchParams()
const membershipFailedError =
searchParams.get("errorCode") === MEMBERSHIP_FAILED_ERROR
const failedToVerifyMembership =
booking.rateDefinition.isMemberRate && !booking.guest.membershipNumber
return (
<>
{/* Customer has manually entered a membership number for which verification failed */}
{membershipFailedError && (
<Alert
type={AlertTypeEnum.Info}
heading={intl.formatMessage({
defaultMessage: "Failed to verify membership",
})}
text={intl.formatMessage({
defaultMessage:
"The first or last name doesn't match the membership number you provided. Your booking(s) is confirmed but to get the membership attached you'll need to present your existing membership number upon check-in. If you have booked with a member discount, you'll either need to present your existing membership number upon check-in, become a member or pay the price difference at the hotel. Signing up is preferably done online before the stay, or we can assist upon arrival.",
})}
/>
)}
{/* For some other reason membership could not be verified */}
{!membershipFailedError && failedToVerifyMembership && (
<Alert
type={AlertTypeEnum.Info}
heading={intl.formatMessage({
defaultMessage: "Failed to verify membership",
})}
text={intl.formatMessage({
defaultMessage:
"Your booking(s) is confirmed but we could not verify your membership. If you have booked with a member discount, you'll either need to present your existing membership number upon check-in, become a member or pay the price difference at the hotel. Signing up is preferably done online before the stay.",
})}
/>
)}
</>
)
}

View File

@@ -13,7 +13,6 @@ import Divider from "@/components/TempDesignSystem/Divider"
import { getIntl } from "@/i18n"
import BookingConfirmationProvider from "@/providers/BookingConfirmationProvider"
import Alerts from "./Alerts"
import Confirmation from "./Confirmation"
import Tracking from "./Tracking"
import { mapRoomState } from "./utils"
@@ -21,9 +20,11 @@ import { mapRoomState } from "./utils"
import styles from "./bookingConfirmation.module.css"
import type { BookingConfirmationProps } from "@/types/components/hotelReservation/bookingConfirmation/bookingConfirmation"
import { AlertTypeEnum } from "@/types/enums/alert"
export default async function BookingConfirmation({
refId,
membershipFailedError,
}: BookingConfirmationProps) {
const bookingConfirmation = await getBookingConfirmation(refId)
@@ -54,7 +55,18 @@ export default async function BookingConfirmation({
>
<Confirmation booking={booking} hotel={hotel} room={room} refId={refId}>
<div className={styles.booking}>
<Alerts booking={booking} />
{membershipFailedError && (
<Alert
type={AlertTypeEnum.Info}
heading={intl.formatMessage({
defaultMessage: "Failed to verify membership",
})}
text={intl.formatMessage({
defaultMessage:
"Your booking(s) is confirmed but we could not verify your membership. If you have booked with a member discount, you'll either need to present your existing membership number upon check-in, become a member or pay the price difference at the hotel. Signing up is preferably done online before the stay.",
})}
/>
)}
<Rooms
booking={booking}
checkInTime={hotel.hotelFacts.checkin.checkInTime}

View File

@@ -6,6 +6,7 @@ import type {
export interface BookingConfirmationProps {
refId: string
membershipFailedError: boolean
}
export interface BookingConfirmationRoom extends Room {