"use client"
import { useIntl } from "react-intl"
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 useLang from "../../hooks/useLang"
import { useHotelFilterStore } from "../../stores/hotel-filters"
import type { Hotel } from "@scandic-hotels/trpc/types/hotel"
type NoAvailabilityAlertProps = {
hotelsLength: number
bookingCode?: string
isAllUnavailable: boolean
isAlternative?: boolean
isBookingCodeRateNotAvailable?: boolean
operaId: Hotel["operaId"]
}
export default function NoAvailabilityAlert({
hotelsLength,
bookingCode,
isAllUnavailable,
isAlternative,
isBookingCodeRateNotAvailable,
operaId,
}: NoAvailabilityAlertProps) {
const intl = useIntl()
const lang = useLang()
const { resultCount, activeFilters } = useHotelFilterStore((state) => ({
resultCount: state.resultCount,
activeFilters: state.activeFilters,
}))
if (activeFilters.length > 0 && resultCount === 0) {
return (
)
}
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 (
)
}
if (!isAllUnavailable) {
return null
}
if (hotelsLength === 1 && !isAlternative && operaId) {
return (
)
}
return (
)
}