From 7213bde423be4a5a76b8e106bf37590c68281b2d Mon Sep 17 00:00:00 2001 From: Simon Emanuelsson Date: Mon, 5 May 2025 16:19:35 +0200 Subject: [PATCH] feat: make sure we update status for when public rates are fetched --- apps/scandic-web/stores/select-rate/index.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/scandic-web/stores/select-rate/index.ts b/apps/scandic-web/stores/select-rate/index.ts index e905dcec3..1a52b8184 100644 --- a/apps/scandic-web/stores/select-rate/index.ts +++ b/apps/scandic-web/stores/select-rate/index.ts @@ -12,6 +12,7 @@ import { findSelectedRate, } from "./helpers" +import { AvailabilityEnum } from "@/types/components/hotelReservation/selectHotel/selectHotel" import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter" import { BookingCodeFilterEnum } from "@/types/enums/bookingCodeFilter" import { RateTypeEnum } from "@/types/enums/rateType" @@ -190,6 +191,16 @@ export function createRatesStore({ }, new Map()) campaign = Array.from(newCampaign.values()) } + + const currentRoomAvailable = + currentRoom.status === AvailabilityEnum.Available + const incomingRoomAvailable = + incomingRoom.status === AvailabilityEnum.Available + let status = AvailabilityEnum.NotAvailable + if (currentRoomAvailable || incomingRoomAvailable) { + status = AvailabilityEnum.Available + } + return { ...currentRoom, campaign, @@ -198,6 +209,7 @@ export function createRatesStore({ ...incomingRoom.products, ], regular: incomingRoom.regular, + status, } }