From ccda1d6cadad59877d1b25179811973aaa63bdc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matilda=20Landstr=C3=B6m?= Date: Tue, 13 May 2025 12:16:35 +0000 Subject: [PATCH] Merged in feat/SW-2505-alternative-hotels-link (pull request #2065) fix(SW-2505): hide alternative hotels link when packages are added * fix(SW-2505): hide alternative hotels link when packages are added Approved-by: Bianca Widstam --- .../Rooms/NoAvailabilityAlert/index.tsx | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) 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} /> )