fix: Price types has changed to doubles in the API
This commit is contained in:
committed by
Michael Zetterberg
parent
8f9e268802
commit
6fb71dea1b
@@ -42,11 +42,11 @@ export const booking: SelectRateSearchParams = {
|
||||
export const breakfastPackage: BreakfastPackage = {
|
||||
code: "BRF1",
|
||||
description: "Breakfast with reservation",
|
||||
localPrice: { currency: "SEK", price: "99", totalPrice: "99" },
|
||||
localPrice: { currency: "SEK", price: 99, totalPrice: 99 },
|
||||
requestedPrice: {
|
||||
currency: "EUR",
|
||||
price: "9",
|
||||
totalPrice: "9",
|
||||
price: 9,
|
||||
totalPrice: 9,
|
||||
},
|
||||
packageType: PackageTypeEnum.BreakfastAdult as const,
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ export default function Breakfast() {
|
||||
ancillary={{
|
||||
title: intl.formatMessage({ id: "Breakfast buffet" }),
|
||||
price: {
|
||||
total: parseInt(pkg.localPrice.price),
|
||||
total: pkg.localPrice.price,
|
||||
currency: pkg.localPrice.currency,
|
||||
included:
|
||||
pkg.code === BreakfastPackageEnum.FREE_MEMBER_BREAKFAST,
|
||||
|
||||
@@ -139,16 +139,16 @@ export default function PriceDetailsTable({
|
||||
/>
|
||||
{room.roomFeatures
|
||||
? room.roomFeatures.map((feature) => (
|
||||
<Row
|
||||
key={feature.code}
|
||||
label={feature.description}
|
||||
value={formatPrice(
|
||||
intl,
|
||||
+feature.localPrice.totalPrice,
|
||||
feature.localPrice.currency
|
||||
)}
|
||||
/>
|
||||
))
|
||||
<Row
|
||||
key={feature.code}
|
||||
label={feature.description}
|
||||
value={formatPrice(
|
||||
intl,
|
||||
+feature.localPrice.totalPrice,
|
||||
feature.localPrice.currency
|
||||
)}
|
||||
/>
|
||||
))
|
||||
: null}
|
||||
{room.bedType ? (
|
||||
<Row
|
||||
@@ -178,7 +178,7 @@ export default function PriceDetailsTable({
|
||||
)}
|
||||
value={formatPrice(
|
||||
intl,
|
||||
parseInt(room.breakfast.localPrice.price) * room.adults,
|
||||
room.breakfast.localPrice.price * room.adults,
|
||||
room.breakfast.localPrice.currency
|
||||
)}
|
||||
/>
|
||||
@@ -207,9 +207,7 @@ export default function PriceDetailsTable({
|
||||
})}
|
||||
value={formatPrice(
|
||||
intl,
|
||||
parseInt(room.breakfast.localPrice.price) *
|
||||
room.adults *
|
||||
diff,
|
||||
room.breakfast.localPrice.price * room.adults * diff,
|
||||
room.breakfast.localPrice.currency
|
||||
)}
|
||||
/>
|
||||
@@ -268,6 +266,6 @@ export default function PriceDetailsTable({
|
||||
</tr>
|
||||
)}
|
||||
</TableSection>
|
||||
</table >
|
||||
</table>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ export default function SummaryUI({
|
||||
<Body color="uiTextHighContrast">
|
||||
{formatPrice(
|
||||
intl,
|
||||
parseInt(feature.localPrice.price),
|
||||
feature.localPrice.price,
|
||||
feature.localPrice.currency
|
||||
)}
|
||||
</Body>
|
||||
@@ -329,9 +329,7 @@ export default function SummaryUI({
|
||||
<Body color="uiTextHighContrast">
|
||||
{formatPrice(
|
||||
intl,
|
||||
parseInt(room.breakfast.localPrice.price) *
|
||||
adults *
|
||||
diff,
|
||||
room.breakfast.localPrice.price * adults * diff,
|
||||
room.breakfast.localPrice.currency
|
||||
)}
|
||||
</Body>
|
||||
|
||||
@@ -527,7 +527,7 @@ export const ancillaryPackagesSchema = z
|
||||
description: item.descriptions.html,
|
||||
imageUrl: item.images[0]?.imageSizes.small,
|
||||
price: {
|
||||
total: parseInt(item.variants.ancillary.price.totalPrice),
|
||||
total: item.variants.ancillary.price.totalPrice,
|
||||
currency: item.variants.ancillary.price.currency,
|
||||
},
|
||||
points: item.variants.ancillaryLoyalty?.points,
|
||||
|
||||
@@ -9,14 +9,14 @@ import { PackageTypeEnum } from "@/types/enums/packages"
|
||||
export const packagePriceSchema = z
|
||||
.object({
|
||||
currency: z.string().default("N/A"),
|
||||
price: z.string(),
|
||||
totalPrice: z.string(),
|
||||
price: z.number(),
|
||||
totalPrice: z.number(),
|
||||
})
|
||||
.optional()
|
||||
.default({
|
||||
currency: "N/A",
|
||||
price: "0",
|
||||
totalPrice: "0",
|
||||
price: 0,
|
||||
totalPrice: 0,
|
||||
})
|
||||
|
||||
const inventorySchema = z.object({
|
||||
|
||||
@@ -205,10 +205,10 @@ export function calcTotalPrice(
|
||||
}
|
||||
|
||||
const breakfastRequestedPrice = room.breakfast
|
||||
? parseInt(room.breakfast.requestedPrice?.price ?? 0)
|
||||
? (room.breakfast.requestedPrice?.price ?? 0)
|
||||
: 0
|
||||
const breakfastLocalPrice = room.breakfast
|
||||
? parseInt(room.breakfast.localPrice?.price ?? 0)
|
||||
? (room.breakfast.localPrice?.price ?? 0)
|
||||
: 0
|
||||
|
||||
const roomFeaturesTotal = room.roomFeatures?.reduce(
|
||||
|
||||
@@ -279,13 +279,11 @@ export function createDetailsStore(
|
||||
|
||||
if (addToTotalPrice) {
|
||||
const breakfastTotalRequestedPrice =
|
||||
parseInt(breakfast.requestedPrice.price) *
|
||||
breakfast.requestedPrice.price *
|
||||
currentRoom.room.adults *
|
||||
nights
|
||||
const breakfastTotalPrice =
|
||||
parseInt(breakfast.localPrice.price) *
|
||||
currentRoom.room.adults *
|
||||
nights
|
||||
breakfast.localPrice.price * currentRoom.room.adults * nights
|
||||
state.totalPrice = {
|
||||
requested: state.totalPrice.requested && {
|
||||
currency: state.totalPrice.requested.currency,
|
||||
@@ -308,13 +306,11 @@ export function createDetailsStore(
|
||||
let currentBreakfastTotalRequestedPrice = 0
|
||||
if (currentRoom.room.breakfast) {
|
||||
currentBreakfastTotalPrice =
|
||||
parseInt(currentRoom.room.breakfast.localPrice.price) *
|
||||
currentRoom.room.breakfast.localPrice.price *
|
||||
currentRoom.room.adults *
|
||||
nights
|
||||
currentBreakfastTotalRequestedPrice =
|
||||
parseInt(
|
||||
currentRoom.room.breakfast.requestedPrice.totalPrice
|
||||
) *
|
||||
currentRoom.room.breakfast.requestedPrice.totalPrice *
|
||||
currentRoom.room.adults *
|
||||
nights
|
||||
currency = currentRoom.room.breakfast.localPrice.currency
|
||||
|
||||
Reference in New Issue
Block a user