import { logger } from "@scandic-hotels/common/logger" import { bookingWidgetErrors } from "../BookingWidget/BookingWidgetForm/schema" import type { IntlShape } from "react-intl" export function getErrorMessage(intl: IntlShape, errorCode?: string) { switch (errorCode) { case bookingWidgetErrors.BOOKING_CODE_INVALID: return intl.formatMessage({ defaultMessage: "Booking code is invalid", }) case bookingWidgetErrors.AGE_REQUIRED: return intl.formatMessage({ defaultMessage: "Age is required", }) case bookingWidgetErrors.BED_CHOICE_REQUIRED: return intl.formatMessage({ defaultMessage: "Bed choice is required", }) case bookingWidgetErrors.CHILDREN_EXCEEDS_ADULTS: return intl.formatMessage({ defaultMessage: "You cannot have more children in adults bed than adults in the room", }) case bookingWidgetErrors.REQUIRED: return intl.formatMessage({ defaultMessage: "Required", }) case bookingWidgetErrors.DESTINATION_REQUIRED: return intl.formatMessage({ defaultMessage: "Destination required", }) case bookingWidgetErrors.MULTIROOM_BOOKING_CODE_UNAVAILABLE: return intl.formatMessage({ defaultMessage: "Multi-room booking is not available with this booking code.", }) case bookingWidgetErrors.MULTIROOM_REWARD_NIGHT_UNAVAILABLE: return intl.formatMessage({ defaultMessage: "Multi-room booking is not available with reward night.", }) case bookingWidgetErrors.CODE_VOUCHER_REWARD_NIGHT_UNAVAILABLE: return intl.formatMessage({ defaultMessage: "Reward nights can't be combined with codes or vouchers.", }) default: logger.warn("Error code not supported:", errorCode) return errorCode } }