Files
Christel Westerberg 2ae3fcb609 Merged in fix/STAY-17-find-my-booking-errors (pull request #3181)
fix: improve error messages in find my booking flow

* fix: improve error messages in find my booking flow


Approved-by: Linus Flood
Approved-by: Erik Tiekstra
2025-11-24 14:46:39 +00:00

41 lines
1.2 KiB
TypeScript

import type { IntlShape } from "react-intl"
export enum FindMyBookingErrorEnum {
BOOKING_NOT_FOUND = "BOOKING_NOT_FOUND",
BOOKING_ACCESS_DENIED = "BOOKING_ACCESS_DENIED",
}
export function getErrorMessage(
intl: IntlShape,
error?: FindMyBookingErrorEnum
) {
switch (error) {
case FindMyBookingErrorEnum.BOOKING_ACCESS_DENIED:
return {
heading: intl.formatMessage({
id: "myStay.accessDenied.loginRequired",
defaultMessage: "You need to be logged in to view your booking",
}),
text: intl.formatMessage({
id: "myStay.accessDenied.loginRequiredMessage",
defaultMessage:
"And you need to be logged in with the same member account that made the booking.",
}),
}
case FindMyBookingErrorEnum.BOOKING_NOT_FOUND:
return {
heading: intl.formatMessage({
id: "myStay.accessDenied.bookingNotFound",
defaultMessage: "We couldn't find your booking",
}),
text: intl.formatMessage({
id: "myStay.accessDenied.bookingNotFoundMessage",
defaultMessage:
"Please make sure you have entered the correct booking details and try again.",
}),
}
default:
return null
}
}