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
This commit is contained in:
@@ -16,13 +16,29 @@ import { AlertTypeEnum } from "@/types/enums/alert"
|
|||||||
export default function NoAvailabilityAlert() {
|
export default function NoAvailabilityAlert() {
|
||||||
const lang = useLang()
|
const lang = useLang()
|
||||||
const intl = useIntl()
|
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 { isFetchingPackages, rooms } = useRoomContext()
|
||||||
|
|
||||||
const noAvailableRooms = rooms.every(
|
const noAvailableRooms = rooms.every(
|
||||||
(roomConfig) => roomConfig.status === AvailabilityEnum.NotAvailable
|
(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) {
|
if (isFetchingPackages) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -39,13 +55,7 @@ export default function NoAvailabilityAlert() {
|
|||||||
defaultMessage: "No availability",
|
defaultMessage: "No availability",
|
||||||
})}
|
})}
|
||||||
text={text}
|
text={text}
|
||||||
link={{
|
link={alertLink}
|
||||||
title: intl.formatMessage({
|
|
||||||
defaultMessage: "See alternative hotels",
|
|
||||||
}),
|
|
||||||
url: `${alternativeHotels(lang)}`,
|
|
||||||
keepSearchParams: true,
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@@ -83,13 +93,7 @@ export default function NoAvailabilityAlert() {
|
|||||||
defaultMessage: "No availability",
|
defaultMessage: "No availability",
|
||||||
})}
|
})}
|
||||||
text={bookingCodeText}
|
text={bookingCodeText}
|
||||||
link={{
|
link={alertLink}
|
||||||
title: intl.formatMessage({
|
|
||||||
defaultMessage: "See alternative hotels",
|
|
||||||
}),
|
|
||||||
url: `${alternativeHotels(lang)}`,
|
|
||||||
keepSearchParams: true,
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user