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:
Anton Gunnarsson
2026-01-15 09:32:17 +00:00
parent c61ddaf94d
commit 16fbdb7ae0
59 changed files with 729 additions and 282 deletions

View File

@@ -15,7 +15,6 @@ import {
} from "./helpers"
import { getRoomPrice, getTotalPrice } from "./priceCalculations"
import type { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
import type { Lang } from "@scandic-hotels/common/constants/language"
import type { BreakfastPackages } from "@scandic-hotels/trpc/routers/hotels/output"
import type { User } from "@scandic-hotels/trpc/types/user"
@@ -41,8 +40,7 @@ export function createDetailsStore(
searchParams: string,
user: User | null,
breakfastPackages: BreakfastPackages,
lang: Lang,
pointsCurrency?: CurrencyEnum
lang: Lang
) {
const isMember = !!user
const nights = dt(initialState.booking.toDate).diff(
@@ -67,23 +65,14 @@ export function createDetailsStore(
...defaultGuestState,
phoneNumberCC: getDefaultCountryFromLang(lang),
},
roomPrice: getRoomPrice(
room.roomRate,
isMember && idx === 0,
pointsCurrency
),
roomPrice: getRoomPrice(room.roomRate, isMember && idx === 0),
specialRequest: {
comment: "",
},
}
})
const initialTotalPrice = getTotalPrice(
initialRooms,
isMember,
nights,
pointsCurrency
)
const initialTotalPrice = getTotalPrice(initialRooms, isMember, nights)
const availableBeds = initialState.rooms.reduce<
DetailsState["availableBeds"]
@@ -184,8 +173,7 @@ export function createDetailsStore(
state.totalPrice = getTotalPrice(
state.rooms.map((r) => r.room),
isMember,
nights,
pointsCurrency
nights
)
const isAllStepsCompleted = checkRoomProgress(
@@ -216,8 +204,7 @@ export function createDetailsStore(
}
currentRoom.roomPrice = getRoomPrice(
currentRoom.roomRate,
isValidMembershipNo || currentRoom.guest.join,
pointsCurrency
isValidMembershipNo || currentRoom.guest.join
)
const nights = dt(state.booking.toDate).diff(
@@ -228,8 +215,7 @@ export function createDetailsStore(
state.totalPrice = getTotalPrice(
state.rooms.map((r) => r.room),
isMember,
nights,
pointsCurrency
nights
)
writeToSessionStorage({
@@ -252,8 +238,7 @@ export function createDetailsStore(
currentRoom.roomPrice = getRoomPrice(
currentRoom.roomRate,
join || !!currentRoom.guest.membershipNo,
pointsCurrency
join || !!currentRoom.guest.membershipNo
)
const nights = dt(state.booking.toDate).diff(
@@ -264,8 +249,7 @@ export function createDetailsStore(
state.totalPrice = getTotalPrice(
state.rooms.map((r) => r.room),
isMember,
nights,
pointsCurrency
nights
)
writeToSessionStorage({
@@ -330,8 +314,7 @@ export function createDetailsStore(
currentRoom.roomPrice = getRoomPrice(
currentRoom.roomRate,
Boolean(data.join || data.membershipNo || isMemberAndRoomOne),
pointsCurrency
Boolean(data.join || data.membershipNo || isMemberAndRoomOne)
)
const nights = dt(state.booking.toDate).diff(
@@ -342,8 +325,7 @@ export function createDetailsStore(
state.totalPrice = getTotalPrice(
state.rooms.map((r) => r.room),
isMember,
nights,
pointsCurrency
nights
)
const isAllStepsCompleted = checkRoomProgress(