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