diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/NoAvailabilityAlert/index.tsx b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/NoAvailabilityAlert/index.tsx index bf2f07130..501b8d78d 100644 --- a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/NoAvailabilityAlert/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/NoAvailabilityAlert/index.tsx @@ -16,13 +16,29 @@ import { AlertTypeEnum } from "@/types/enums/alert" export default function NoAvailabilityAlert() { const lang = useLang() const intl = useIntl() - const bookingCode = useRatesStore((state) => state.booking.bookingCode) + const [bookingCode, selectedRooms, activeRoom] = useRatesStore((state) => [ + state.booking.bookingCode, + state.rooms, + state.activeRoom, + ]) + const { isFetchingPackages, rooms } = useRoomContext() const noAvailableRooms = rooms.every( (roomConfig) => roomConfig.status === AvailabilityEnum.NotAvailable ) + const alertLink = + selectedRooms[activeRoom].selectedPackages.length === 0 + ? { + title: intl.formatMessage({ + defaultMessage: "See alternative hotels", + }), + url: `${alternativeHotels(lang)}`, + keepSearchParams: true, + } + : null + if (isFetchingPackages) { return null } @@ -39,13 +55,7 @@ export default function NoAvailabilityAlert() { defaultMessage: "No availability", })} text={text} - link={{ - title: intl.formatMessage({ - defaultMessage: "See alternative hotels", - }), - url: `${alternativeHotels(lang)}`, - keepSearchParams: true, - }} + link={alertLink} /> ) @@ -83,13 +93,7 @@ export default function NoAvailabilityAlert() { defaultMessage: "No availability", })} text={bookingCodeText} - link={{ - title: intl.formatMessage({ - defaultMessage: "See alternative hotels", - }), - url: `${alternativeHotels(lang)}`, - keepSearchParams: true, - }} + link={alertLink} /> )