fix: avoid localizing currencies and default missing value to N/A
This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
import deepmerge from "deepmerge"
|
||||
import isEqual from "fast-deep-equal"
|
||||
|
||||
import { Lang } from "@/constants/languages"
|
||||
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
import { arrayMerge } from "@/utils/merge"
|
||||
|
||||
import { detailsStorageName } from "."
|
||||
|
||||
import type { SelectRateSearchParams } from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||
import { CurrencyEnum } from "@/types/enums/currency"
|
||||
import type { StepEnum } from "@/types/enums/step"
|
||||
import type {
|
||||
DetailsState,
|
||||
@@ -19,24 +15,6 @@ import type {
|
||||
} from "@/types/stores/enter-details"
|
||||
import type { SafeUser } from "@/types/user"
|
||||
|
||||
export function langToCurrency() {
|
||||
const lang = getLang()
|
||||
switch (lang) {
|
||||
case Lang.da:
|
||||
return CurrencyEnum.DKK
|
||||
case Lang.de:
|
||||
case Lang.en:
|
||||
case Lang.fi:
|
||||
return CurrencyEnum.EUR
|
||||
case Lang.no:
|
||||
return CurrencyEnum.NOK
|
||||
case Lang.sv:
|
||||
return CurrencyEnum.SEK
|
||||
default:
|
||||
throw new Error(`Unexpected lang: ${lang}`)
|
||||
}
|
||||
}
|
||||
|
||||
export function extractGuestFromUser(user: NonNullable<SafeUser>) {
|
||||
return {
|
||||
countryCode: user.address.countryCode?.toString(),
|
||||
|
||||
@@ -13,7 +13,6 @@ import {
|
||||
extractGuestFromUser,
|
||||
getInitialRoomPrice,
|
||||
getInitialTotalPrice,
|
||||
langToCurrency,
|
||||
navigate,
|
||||
writeToSessionStorage,
|
||||
} from "./helpers"
|
||||
@@ -233,7 +232,7 @@ export function createDetailsStore(
|
||||
}
|
||||
|
||||
if (subtractFromTotalPrice) {
|
||||
let currency = state.totalPrice.local.currency ?? langToCurrency()
|
||||
let currency = state.totalPrice.local.currency
|
||||
let currentBreakfastTotalPrice = 0
|
||||
let currentBreakfastTotalRequestedPrice = 0
|
||||
if (state.breakfast) {
|
||||
|
||||
@@ -10,7 +10,6 @@ import EnterDetailsProvider from "@/providers/EnterDetailsProvider"
|
||||
import { detailsStorageName, useEnterDetailsStore } from "."
|
||||
|
||||
import { BreakfastPackageEnum } from "@/types/enums/breakfast"
|
||||
import { CurrencyEnum } from "@/types/enums/currency"
|
||||
import { PackageTypeEnum } from "@/types/enums/packages"
|
||||
import { StepEnum } from "@/types/enums/step"
|
||||
import type { PersistedState } from "@/types/stores/enter-details"
|
||||
@@ -84,12 +83,12 @@ const breakfastPackages = [
|
||||
code: BreakfastPackageEnum.REGULAR_BREAKFAST,
|
||||
description: "Breakfast with reservation",
|
||||
localPrice: {
|
||||
currency: CurrencyEnum.SEK,
|
||||
currency: "SEK",
|
||||
price: "99",
|
||||
totalPrice: "99",
|
||||
},
|
||||
requestedPrice: {
|
||||
currency: CurrencyEnum.EUR,
|
||||
currency: "EUR",
|
||||
price: "9",
|
||||
totalPrice: "9",
|
||||
},
|
||||
@@ -108,7 +107,7 @@ function Wrapper({ children }: PropsWithChildren) {
|
||||
memberRate: {
|
||||
rateCode: "PLSA2BEU",
|
||||
localPrice: {
|
||||
currency: CurrencyEnum.EUR,
|
||||
currency: "EUR",
|
||||
pricePerNight: 100,
|
||||
pricePerStay: 200,
|
||||
},
|
||||
@@ -116,7 +115,7 @@ function Wrapper({ children }: PropsWithChildren) {
|
||||
publicRate: {
|
||||
rateCode: "SAVEEU",
|
||||
localPrice: {
|
||||
currency: CurrencyEnum.EUR,
|
||||
currency: "EUR",
|
||||
pricePerNight: 100,
|
||||
pricePerStay: 200,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user