fix: avoid localizing currencies and default missing value to N/A

This commit is contained in:
Christel Westerberg
2025-01-07 15:48:44 +01:00
parent 5018cba623
commit a3331850a2
12 changed files with 22 additions and 68 deletions

View File

@@ -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(),

View File

@@ -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) {

View File

@@ -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,
},