Merged in feat/SW-3526-show-sas-eb-points-rate-in- (pull request #2933)
feat(SW-3526): Show EB points rate and label in booking flow * feat(SW-3526): Show EB points rate and label in booking flow * feat(SW-3526) Optimized points currency code * feat(SW-3526) Removed extra multiplication for token expiry after rebase * feat(SW-3526): Updated to exhaustive check and thow if type error Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
writeToSessionStorage,
|
||||
} from "./helpers"
|
||||
|
||||
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"
|
||||
@@ -43,7 +44,8 @@ export function createDetailsStore(
|
||||
searchParams: string,
|
||||
user: User | null,
|
||||
breakfastPackages: BreakfastPackages,
|
||||
lang: Lang
|
||||
lang: Lang,
|
||||
pointsCurrency?: CurrencyEnum
|
||||
) {
|
||||
const isMember = !!user
|
||||
const nights = dt(initialState.booking.toDate).diff(
|
||||
@@ -68,14 +70,23 @@ export function createDetailsStore(
|
||||
...defaultGuestState,
|
||||
phoneNumberCC: getDefaultCountryFromLang(lang),
|
||||
},
|
||||
roomPrice: getRoomPrice(room.roomRate, isMember && idx === 0),
|
||||
roomPrice: getRoomPrice(
|
||||
room.roomRate,
|
||||
isMember && idx === 0,
|
||||
pointsCurrency
|
||||
),
|
||||
specialRequest: {
|
||||
comment: "",
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
const initialTotalPrice = getTotalPrice(initialRooms, isMember, nights)
|
||||
const initialTotalPrice = getTotalPrice(
|
||||
initialRooms,
|
||||
isMember,
|
||||
nights,
|
||||
pointsCurrency
|
||||
)
|
||||
|
||||
const availableBeds = initialState.rooms.reduce<
|
||||
DetailsState["availableBeds"]
|
||||
@@ -175,7 +186,8 @@ export function createDetailsStore(
|
||||
state.totalPrice = getTotalPrice(
|
||||
state.rooms.map((r) => r.room),
|
||||
isMember,
|
||||
nights
|
||||
nights,
|
||||
pointsCurrency
|
||||
)
|
||||
|
||||
const isAllStepsCompleted = checkRoomProgress(
|
||||
@@ -206,7 +218,8 @@ export function createDetailsStore(
|
||||
}
|
||||
currentRoom.roomPrice = getRoomPrice(
|
||||
currentRoom.roomRate,
|
||||
isValidMembershipNo || currentRoom.guest.join
|
||||
isValidMembershipNo || currentRoom.guest.join,
|
||||
pointsCurrency
|
||||
)
|
||||
|
||||
const nights = dt(state.booking.toDate).diff(
|
||||
@@ -217,7 +230,8 @@ export function createDetailsStore(
|
||||
state.totalPrice = getTotalPrice(
|
||||
state.rooms.map((r) => r.room),
|
||||
isMember,
|
||||
nights
|
||||
nights,
|
||||
pointsCurrency
|
||||
)
|
||||
|
||||
writeToSessionStorage({
|
||||
@@ -240,7 +254,8 @@ export function createDetailsStore(
|
||||
|
||||
currentRoom.roomPrice = getRoomPrice(
|
||||
currentRoom.roomRate,
|
||||
join || !!currentRoom.guest.membershipNo
|
||||
join || !!currentRoom.guest.membershipNo,
|
||||
pointsCurrency
|
||||
)
|
||||
|
||||
const nights = dt(state.booking.toDate).diff(
|
||||
@@ -251,7 +266,8 @@ export function createDetailsStore(
|
||||
state.totalPrice = getTotalPrice(
|
||||
state.rooms.map((r) => r.room),
|
||||
isMember,
|
||||
nights
|
||||
nights,
|
||||
pointsCurrency
|
||||
)
|
||||
|
||||
writeToSessionStorage({
|
||||
@@ -316,7 +332,8 @@ export function createDetailsStore(
|
||||
|
||||
currentRoom.roomPrice = getRoomPrice(
|
||||
currentRoom.roomRate,
|
||||
Boolean(data.join || data.membershipNo || isMemberAndRoomOne)
|
||||
Boolean(data.join || data.membershipNo || isMemberAndRoomOne),
|
||||
pointsCurrency
|
||||
)
|
||||
|
||||
const nights = dt(state.booking.toDate).diff(
|
||||
@@ -327,7 +344,8 @@ export function createDetailsStore(
|
||||
state.totalPrice = getTotalPrice(
|
||||
state.rooms.map((r) => r.room),
|
||||
isMember,
|
||||
nights
|
||||
nights,
|
||||
pointsCurrency
|
||||
)
|
||||
|
||||
const isAllStepsCompleted = checkRoomProgress(
|
||||
|
||||
Reference in New Issue
Block a user