diff --git a/components/HotelReservation/BookingConfirmation/index.tsx b/components/HotelReservation/BookingConfirmation/index.tsx index fbd1f5093..a1d63e84a 100644 --- a/components/HotelReservation/BookingConfirmation/index.tsx +++ b/components/HotelReservation/BookingConfirmation/index.tsx @@ -16,7 +16,6 @@ import { type TrackingSDKPageData, type TrackingSDKPaymentInfo, } from "@/types/components/tracking" -import { CurrencyEnum } from "@/types/enums/currency" export default async function BookingConfirmation({ confirmationNumber, @@ -60,7 +59,7 @@ export default async function BookingConfirmation({ rateCodeName: booking.rateDefinition.rateCode ?? undefined, rateCodeCancellationRule: booking.rateDefinition?.cancellationText ?? undefined, - revenueCurrencyCode: CurrencyEnum[booking.currencyCode], + revenueCurrencyCode: booking.currencyCode, breakfastOption: booking.rateDefinition.breakfastIncluded ? "breakfast buffet" : "no breakfast", diff --git a/components/HotelReservation/HotelCardDialogListing/utils.ts b/components/HotelReservation/HotelCardDialogListing/utils.ts index 141444730..592002097 100644 --- a/components/HotelReservation/HotelCardDialogListing/utils.ts +++ b/components/HotelReservation/HotelCardDialogListing/utils.ts @@ -15,7 +15,7 @@ export function getHotelPins(hotels: HotelData[]): HotelPin[] { currency: hotel.price?.public?.localPrice.currency || hotel.price?.member?.localPrice.currency || - null, + "N/A", images: [ hotel.hotelData.hotelContent.images, ...(hotel.hotelData.gallery?.heroImages ?? []), diff --git a/server/routers/booking/output.ts b/server/routers/booking/output.ts index 14006d07a..f3e343d1e 100644 --- a/server/routers/booking/output.ts +++ b/server/routers/booking/output.ts @@ -4,8 +4,6 @@ import { ChildBedTypeEnum } from "@/constants/booking" import { phoneValidator } from "@/utils/phoneValidator" -import { CurrencyEnum } from "@/types/enums/currency" - // MUTATION export const createBookingSchema = z .object({ @@ -80,7 +78,7 @@ const guestSchema = z.object({ const packageSchema = z.object({ code: z.string().nullable().default(""), - currency: z.nativeEnum(CurrencyEnum), + currency: z.string(), quantity: z.number().int(), totalPrice: z.number(), totalQuantity: z.number().int(), @@ -110,7 +108,7 @@ export const bookingConfirmationSchema = z extraBedTypes: z.array(extraBedTypesSchema).default([]), computedReservationStatus: z.string().nullable().default(""), confirmationNumber: z.string().nullable().default(""), - currencyCode: z.nativeEnum(CurrencyEnum), + currencyCode: z.string(), guest: guestSchema, hotelId: z.string(), packages: z.array(packageSchema).default([]), diff --git a/server/routers/hotels/output.ts b/server/routers/hotels/output.ts index 7ba5ef899..a9e6b938f 100644 --- a/server/routers/hotels/output.ts +++ b/server/routers/hotels/output.ts @@ -10,7 +10,6 @@ import { specialAlertsSchema } from "./schemas/specialAlerts" import { getPoiGroupByCategoryName } from "./utils" import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter" -import { CurrencyEnum } from "@/types/enums/currency" import { FacilityEnum } from "@/types/enums/facilities" import { PackageTypeEnum } from "@/types/enums/packages" import type { RestaurantData, RoomData } from "@/types/hotel" @@ -219,7 +218,7 @@ const parkingPricingSchema = z.object({ freeParking: z.boolean(), paymentType: z.string().optional(), localCurrency: z.object({ - currency: z.string().optional(), + currency: z.string().default("N/A"), range: z.object({ min: z.number().optional(), max: z.number().optional(), @@ -247,7 +246,7 @@ const parkingPricingSchema = z.object({ }), requestedCurrency: z .object({ - currency: z.string().optional(), + currency: z.string().default("N/A"), range: z .object({ min: z.number().optional(), @@ -493,7 +492,7 @@ const linksSchema = z.object({ export const priceSchema = z.object({ pricePerNight: z.coerce.number(), pricePerStay: z.coerce.number(), - currency: z.nativeEnum(CurrencyEnum), + currency: z.string().default("N/A"), }) export const productTypePriceSchema = z.object({ @@ -509,7 +508,7 @@ const productSchema = z.object({ rateCode: "", rateType: "", localPrice: { - currency: CurrencyEnum.SEK, + currency: "N/A", pricePerNight: 0, pricePerStay: 0, }, @@ -666,7 +665,7 @@ export const apiCountriesSchema = z.object({ .array( z.object({ attributes: z.object({ - currency: z.string().optional(), + currency: z.string().default("N/A"), name: z.string(), }), hotelInformationSystemId: z.number().optional(), @@ -813,7 +812,7 @@ export const apiLocationsSchema = z.object({ }) export const packagePriceSchema = z.object({ - currency: z.nativeEnum(CurrencyEnum), + currency: z.string().default("N/A"), price: z.string(), totalPrice: z.string(), }) diff --git a/server/routers/hotels/schemas/packages.ts b/server/routers/hotels/schemas/packages.ts index 988cf1ac5..035882fc4 100644 --- a/server/routers/hotels/schemas/packages.ts +++ b/server/routers/hotels/schemas/packages.ts @@ -1,7 +1,6 @@ import { z } from "zod" import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter" -import { CurrencyEnum } from "@/types/enums/currency" export const getRoomPackagesInputSchema = z.object({ hotelId: z.string(), @@ -14,13 +13,13 @@ export const getRoomPackagesInputSchema = z.object({ export const packagePriceSchema = z .object({ - currency: z.nativeEnum(CurrencyEnum), + currency: z.string().default("N/A"), price: z.string(), totalPrice: z.string(), }) .optional() .default({ - currency: CurrencyEnum.SEK, + currency: "N/A", price: "0", totalPrice: "0", }) // TODO: Remove optional and default when the API change has been deployed diff --git a/stores/enter-details/helpers.ts b/stores/enter-details/helpers.ts index 58eeb1b90..f1f22a983 100644 --- a/stores/enter-details/helpers.ts +++ b/stores/enter-details/helpers.ts @@ -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) { return { countryCode: user.address.countryCode?.toString(), diff --git a/stores/enter-details/index.ts b/stores/enter-details/index.ts index ed52b138e..cb5263909 100644 --- a/stores/enter-details/index.ts +++ b/stores/enter-details/index.ts @@ -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) { diff --git a/stores/enter-details/useEnterDetailsStore.test.tsx b/stores/enter-details/useEnterDetailsStore.test.tsx index 29d8bc2da..a8db55157 100644 --- a/stores/enter-details/useEnterDetailsStore.test.tsx +++ b/stores/enter-details/useEnterDetailsStore.test.tsx @@ -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, }, diff --git a/types/components/hotelReservation/selectHotel/map.ts b/types/components/hotelReservation/selectHotel/map.ts index bd2bf0033..897234b0f 100644 --- a/types/components/hotelReservation/selectHotel/map.ts +++ b/types/components/hotelReservation/selectHotel/map.ts @@ -29,7 +29,7 @@ export type HotelPin = { coordinates: Coordinates publicPrice: number | null memberPrice: number | null - currency: string | null + currency: string images: { imageSizes: ImageSizes metaData: ImageMetaData diff --git a/types/components/hotelReservation/signupPromo.ts b/types/components/hotelReservation/signupPromo.ts index 025bb0531..ff0024e64 100644 --- a/types/components/hotelReservation/signupPromo.ts +++ b/types/components/hotelReservation/signupPromo.ts @@ -1,9 +1,7 @@ -import type { CurrencyEnum } from "@/types/enums/currency" - export interface SignupPromoProps { memberPrice: { amount: number - currency: CurrencyEnum + currency: string } badgeContent?: string } diff --git a/types/enums/currency.ts b/types/enums/currency.ts deleted file mode 100644 index c04ed8450..000000000 --- a/types/enums/currency.ts +++ /dev/null @@ -1,7 +0,0 @@ -export enum CurrencyEnum { - DKK = "DKK", - EUR = "EUR", - NOK = "NOK", - PLN = "PLN", - SEK = "SEK", -} diff --git a/utils/numberFormatting.ts b/utils/numberFormatting.ts index 664067cc8..213297a27 100644 --- a/utils/numberFormatting.ts +++ b/utils/numberFormatting.ts @@ -16,17 +16,9 @@ export function getSingleDecimal(n: Number | string) { * @param currency - currency code * @returns localized and formatted number in string type with currency */ -export function formatPrice( - intl: IntlShape, - price: number, - currency?: string | null -) { - if (!currency) { - return intl.formatNumber(price) - } - return intl.formatNumber(price, { - style: "currency", - currency, +export function formatPrice(intl: IntlShape, price: number, currency: string) { + const localizedPrice = intl.formatNumber(price, { minimumFractionDigits: 0, }) + return `${localizedPrice} ${currency}` }