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
41 lines
1.2 KiB
TypeScript
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
|
|
}
|
|
}
|