Merged in fix/refactor-currency-display (pull request #3434)
fix(SW-3616): Handle EuroBonus point type everywhere * Add tests to formatPrice * formatPrice * More work replacing config with api points type * More work replacing config with api points type * More fixing with currency * maybe actually fixed it * Fix MyStay * Clean up * Fix comments * Merge branch 'master' into fix/refactor-currency-display * Fix calculateTotalPrice for EB points + SF points + cash Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -34,9 +34,10 @@ export function mapToPrice(room: Room) {
|
||||
return {
|
||||
redemption: {
|
||||
additionalPricePerStay: room.roomPrice.perStay.local.price,
|
||||
currency: room.currencyCode,
|
||||
currency: CurrencyEnum.POINTS,
|
||||
pointsPerNight: room.roomPoints / nights,
|
||||
pointsPerStay: room.roomPoints,
|
||||
pointsType: room.roomPointType,
|
||||
},
|
||||
}
|
||||
case PriceTypeEnum.voucher:
|
||||
@@ -71,16 +72,6 @@ export function calculateTotalPrice(rooms: Room[], currency: CurrencyEnum) {
|
||||
break
|
||||
case PriceTypeEnum.points:
|
||||
{
|
||||
if (
|
||||
room.roomPoints &&
|
||||
room.roomPointType &&
|
||||
room.roomPointType !== "Scandic"
|
||||
) {
|
||||
total.local.currency =
|
||||
roomPointTypeToCurrencyMap[room.roomPointType]
|
||||
total.local.price = total.local.price + room.roomPoints
|
||||
break
|
||||
}
|
||||
total.local.currency = CurrencyEnum.POINTS
|
||||
total.local.price = total.local.price + room.totalPoints
|
||||
}
|
||||
@@ -95,6 +86,17 @@ export function calculateTotalPrice(rooms: Room[], currency: CurrencyEnum) {
|
||||
case PriceTypeEnum.cheque:
|
||||
case PriceTypeEnum.points:
|
||||
{
|
||||
if (
|
||||
room.roomPoints &&
|
||||
room.roomPointType &&
|
||||
room.roomPointType !== "Scandic"
|
||||
) {
|
||||
total.local.currency = CurrencyEnum.POINTS
|
||||
total.local.price = total.local.price + room.roomPoints
|
||||
total.local.pointsType = room.roomPointType
|
||||
break
|
||||
}
|
||||
|
||||
if (room.totalPrice) {
|
||||
total.local.additionalPrice =
|
||||
(total.local.additionalPrice || 0) + room.totalPrice
|
||||
@@ -140,16 +142,9 @@ export function calculateTotalPrice(rooms: Room[], currency: CurrencyEnum) {
|
||||
local: {
|
||||
currency,
|
||||
price: 0,
|
||||
pointsType: undefined,
|
||||
},
|
||||
requested: undefined,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const roomPointTypeToCurrencyMap: Record<
|
||||
NonNullable<Room["roomPointType"]>,
|
||||
CurrencyEnum
|
||||
> = {
|
||||
Scandic: CurrencyEnum.POINTS,
|
||||
EuroBonus: CurrencyEnum.EUROBONUS,
|
||||
}
|
||||
|
||||
@@ -9,16 +9,15 @@ import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConf
|
||||
|
||||
import { PriceTypeEnum } from "@/types/components/hotelReservation/myStay/myStay"
|
||||
|
||||
interface PriceTypeProps
|
||||
extends Pick<
|
||||
BookingConfirmation["booking"],
|
||||
| "cheques"
|
||||
| "currencyCode"
|
||||
| "rateDefinition"
|
||||
| "totalPoints"
|
||||
| "totalPrice"
|
||||
| "vouchers"
|
||||
> {
|
||||
interface PriceTypeProps extends Pick<
|
||||
BookingConfirmation["booking"],
|
||||
| "cheques"
|
||||
| "currencyCode"
|
||||
| "rateDefinition"
|
||||
| "totalPoints"
|
||||
| "totalPrice"
|
||||
| "vouchers"
|
||||
> {
|
||||
formattedTotalPrice: string
|
||||
isCancelled: boolean
|
||||
priceType: PriceTypeEnum
|
||||
|
||||
@@ -10,7 +10,6 @@ export default function TotalPrice() {
|
||||
const { bookedRoom, totalPrice } = useMyStayStore((state) => ({
|
||||
bookedRoom: state.bookedRoom,
|
||||
totalPrice: state.totalPrice,
|
||||
rooms: state.rooms,
|
||||
}))
|
||||
return (
|
||||
<Price
|
||||
|
||||
Reference in New Issue
Block a user