Merged in feat/SW-1308-booking-codes-track-b (pull request #1607)
Feat/SW-1308 booking codes track b * feat: SW-1308 Booking codes track b * feat: SW-1308 Booking codes Track B implementation * feat: SW-1308 Optimized after rebase Approved-by: Arvid Norlin
This commit is contained in:
@@ -11,6 +11,8 @@ import { DetailsContext } from "@/contexts/Details"
|
||||
import {
|
||||
add,
|
||||
calcTotalPrice,
|
||||
calculateChequePrice,
|
||||
calculateVoucherPrice,
|
||||
checkRoomProgress,
|
||||
extractGuestFromUser,
|
||||
findNextInvalidStep,
|
||||
@@ -56,11 +58,22 @@ export function createDetailsStore(
|
||||
const isRedemption =
|
||||
new URLSearchParams(searchParams).get("searchtype") === REDEMPTION
|
||||
|
||||
const isVoucher = initialState.rooms.some((room) => room.roomRate.voucherRate)
|
||||
const isCorpChq = initialState.rooms.some((room) => room.roomRate.chequeRate)
|
||||
|
||||
let initialTotalPrice: Price
|
||||
if (isRedemption && initialState.rooms[0].roomRate.redemptionRate) {
|
||||
initialTotalPrice = PointsPriceSchema.parse(
|
||||
initialState.rooms[0].roomRate.redemptionRate
|
||||
)
|
||||
} else if (isVoucher) {
|
||||
initialTotalPrice = calculateVoucherPrice(
|
||||
initialState.rooms.map((r) => r.roomRate)
|
||||
)
|
||||
} else if (isCorpChq) {
|
||||
initialTotalPrice = calculateChequePrice(
|
||||
initialState.rooms.map((r) => r.roomRate)
|
||||
)
|
||||
} else {
|
||||
initialTotalPrice = getTotalPrice(
|
||||
initialState.rooms.map((r) => r.roomRate),
|
||||
@@ -270,7 +283,7 @@ export function createDetailsStore(
|
||||
const currentTotalPriceRequested = state.totalPrice.requested
|
||||
let stateTotalRequestedPrice = 0
|
||||
if (currentTotalPriceRequested) {
|
||||
stateTotalRequestedPrice = currentTotalPriceRequested.price
|
||||
stateTotalRequestedPrice = currentTotalPriceRequested.price ?? 0
|
||||
}
|
||||
|
||||
const stateTotalLocalPrice = state.totalPrice.local.price
|
||||
@@ -305,7 +318,7 @@ export function createDetailsStore(
|
||||
},
|
||||
local: {
|
||||
currency: breakfast.localPrice.currency,
|
||||
price: stateTotalLocalPrice + breakfastTotalPrice,
|
||||
price: stateTotalLocalPrice ?? 0 + breakfastTotalPrice,
|
||||
regularPrice: stateTotalLocalRegularPrice
|
||||
? stateTotalLocalRegularPrice + breakfastTotalPrice
|
||||
: undefined,
|
||||
|
||||
Reference in New Issue
Block a user