Feat/SW-1368 1369 Guarantee late arrival * feat(SW-1368-SW-1369): guarantee late arrival for confirmation page and my stay * feat(SW-1368-SW-1369): guarantee late arrival updated design * feat(SW-1368-SW-1369): add translations * feat(SW-1368-SW-1369): add translations * feat(SW-1368-SW-1369): fix merge with master * feat(SW-1368-SW-1369): add translations * feat(SW-1368-SW-1369): add redirect with refId * feat(SW-1368-SW-1369): if booking completed redirect to confirmation page * feat(SW-1368-SW-1369): fix comments pr * feat(SW-1368-SW-1369): fix comments pr * feat(SW-1368-SW-1369): fix rebase master * feat(SW-1368-SW-1369): fix duplicate flex rate check * feat(SW-1368-SW-1369): if any room is flex, card must be used * feat(SW-1368-SW-1369): move callback route * feat(SW-1368-SW-1369): top align checkbox * feat(SW-1368-SW-1369): top align checkbox Approved-by: Tobias Johansson Approved-by: Niclas Edenvin
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import { PaymentMethodEnum } from "@/constants/booking"
|
|
|
|
import type { RoomState } from "@/types/stores/enter-details"
|
|
|
|
export function isPaymentMethodEnum(value: string): value is PaymentMethodEnum {
|
|
return Object.values<string>(PaymentMethodEnum).includes(value)
|
|
}
|
|
|
|
export function hasFlexibleRate({ room }: RoomState): boolean {
|
|
return room.isFlexRate
|
|
}
|
|
|
|
export function hasPrepaidRate({ room }: RoomState): boolean {
|
|
return !room.isFlexRate
|
|
}
|
|
|
|
export function calculateTotalRoomPrice({ room }: RoomState) {
|
|
let totalPrice = room.roomPrice.perStay.local.price
|
|
|
|
if (room.breakfast) {
|
|
totalPrice += Number(room.breakfast.localPrice.totalPrice) * room.adults
|
|
}
|
|
|
|
if (room.roomFeatures) {
|
|
room.roomFeatures.forEach((pkg) => {
|
|
totalPrice += Number(pkg.localPrice.price)
|
|
})
|
|
}
|
|
|
|
let comparisonPrice = totalPrice
|
|
|
|
const isMember = room.guest.join || room.guest.membershipNo
|
|
if (isMember) {
|
|
const publicPrice = room.roomRate.publicRate?.localPrice.pricePerStay ?? 0
|
|
const memberPrice = room.roomRate.memberRate?.localPrice.pricePerStay ?? 0
|
|
const diff = publicPrice - memberPrice
|
|
comparisonPrice = totalPrice + diff
|
|
}
|
|
|
|
return {
|
|
totalPrice,
|
|
comparisonPrice,
|
|
}
|
|
}
|