chore(SW-3246): Moved Alert component into design system * chore(SW-3246): Moved Alert component into design system * chore(SW-3246): Optimsed code and imports * chore(SW-3246): Moved type AlertTypeEnum and other to common package Approved-by: Anton Gunnarsson
78 lines
2.1 KiB
TypeScript
78 lines
2.1 KiB
TypeScript
import { AlertTypeEnum } from "@scandic-hotels/common/constants/alert"
|
|
import { alternativeHotels } from "@scandic-hotels/common/constants/routes/hotelReservation"
|
|
import { Alert } from "@scandic-hotels/design-system/Alert"
|
|
|
|
import { getIntl } from "@/i18n"
|
|
import { getLang } from "@/i18n/serverContext"
|
|
|
|
import type { NoAvailabilityAlertProp } from "@/types/components/hotelReservation/selectHotel/noAvailabilityAlert"
|
|
|
|
export default async function NoAvailabilityAlert({
|
|
hotelsLength,
|
|
bookingCode,
|
|
isAllUnavailable,
|
|
isAlternative,
|
|
isBookingCodeRateNotAvailable,
|
|
operaId,
|
|
}: NoAvailabilityAlertProp) {
|
|
const intl = await getIntl()
|
|
const lang = await getLang()
|
|
|
|
if (bookingCode && isBookingCodeRateNotAvailable && hotelsLength > 0) {
|
|
const bookingCodeText = intl.formatMessage(
|
|
{
|
|
defaultMessage:
|
|
"We found no available rooms using this booking code ({bookingCode}). See available rates below.",
|
|
},
|
|
{ bookingCode }
|
|
)
|
|
return (
|
|
<Alert
|
|
type={AlertTypeEnum.Info}
|
|
heading={intl.formatMessage({
|
|
defaultMessage: "No availability",
|
|
})}
|
|
text={bookingCodeText}
|
|
/>
|
|
)
|
|
}
|
|
|
|
if (!isAllUnavailable) {
|
|
return null
|
|
}
|
|
|
|
if (hotelsLength === 1 && !isAlternative && operaId) {
|
|
return (
|
|
<Alert
|
|
type={AlertTypeEnum.Info}
|
|
heading={intl.formatMessage({
|
|
defaultMessage: "No availability",
|
|
})}
|
|
text={intl.formatMessage({
|
|
defaultMessage:
|
|
"Please try and change your search for this destination or see alternative hotels.",
|
|
})}
|
|
link={{
|
|
title: intl.formatMessage({
|
|
defaultMessage: "See alternative hotels",
|
|
}),
|
|
url: `${alternativeHotels(lang)}?hotel=${operaId}`,
|
|
keepSearchParams: true,
|
|
}}
|
|
/>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<Alert
|
|
type={AlertTypeEnum.Info}
|
|
heading={intl.formatMessage({
|
|
defaultMessage: "No availability",
|
|
})}
|
|
text={intl.formatMessage({
|
|
defaultMessage: "There are no rooms available that match your request.",
|
|
})}
|
|
/>
|
|
)
|
|
}
|