Merged in fix/SW-2249-missing-currency (pull request #2159)
fix(SW-2249): Added default currency to summary and price details modal * fix(SW-2249): Added default currency to summary and price details modal Approved-by: Hrishikesh Vaipurkar
This commit is contained in:
@@ -378,6 +378,7 @@ export function createDetailsStore(
|
||||
searchParamString: searchParams,
|
||||
totalPrice: initialTotalPrice,
|
||||
vat: initialState.vat,
|
||||
defaultCurrency: breakfastPackages[0].localPrice.currency,
|
||||
preSubmitCallbacks: {},
|
||||
|
||||
actions: {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
||||
import { CurrencyEnum } from "@/types/enums/currency"
|
||||
import type { AvailabilityError } from "@/types/stores/rates"
|
||||
import type {
|
||||
Product,
|
||||
RoomConfiguration,
|
||||
RoomsAvailability,
|
||||
} from "@/types/trpc/routers/hotel/roomAvailability"
|
||||
|
||||
export function findProduct(
|
||||
@@ -117,3 +119,28 @@ export function clearRoomSelectionFromUrl(
|
||||
searchParams.delete(`room[${roomIdx}].roomtype`)
|
||||
return searchParams
|
||||
}
|
||||
|
||||
export function findDefaultCurrency(
|
||||
roomsAvailability: (RoomsAvailability | AvailabilityError)[] | undefined
|
||||
) {
|
||||
if (!roomsAvailability || !roomsAvailability.length) {
|
||||
return CurrencyEnum.Unknown
|
||||
}
|
||||
|
||||
const availability = roomsAvailability.filter(
|
||||
(room): room is RoomsAvailability => {
|
||||
if ("error" in room) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
)[0]
|
||||
|
||||
const pkg = availability?.packages.find((pkg) => pkg.localPrice.currency)
|
||||
if (!pkg) {
|
||||
return CurrencyEnum.Unknown
|
||||
}
|
||||
|
||||
const defaultCurrency = pkg.localPrice.currency
|
||||
return defaultCurrency
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { RatesContext } from "@/contexts/Rates"
|
||||
|
||||
import {
|
||||
clearRoomSelectionFromUrl,
|
||||
findDefaultCurrency,
|
||||
findProductInRoom,
|
||||
findSelectedRate,
|
||||
} from "./helpers"
|
||||
@@ -118,6 +119,8 @@ export function createRatesStore({
|
||||
|
||||
const isRedemptionBooking = booking.searchType === REDEMPTION
|
||||
|
||||
const defaultCurrency = findDefaultCurrency(roomsAvailability)
|
||||
|
||||
return create<RatesState>()((set) => {
|
||||
return {
|
||||
activeRoom,
|
||||
@@ -133,6 +136,7 @@ export function createRatesStore({
|
||||
roomsAvailability,
|
||||
searchParams,
|
||||
vat,
|
||||
defaultCurrency,
|
||||
rooms: booking.rooms.map((room, idx) => {
|
||||
const roomConfiguration = roomConfigurations[idx]
|
||||
const roomPackages = roomsPackages[idx]
|
||||
|
||||
Reference in New Issue
Block a user