fix: refacotr away optional pricing
This commit is contained in:
@@ -55,12 +55,12 @@ export default async function SummaryPage({
|
|||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
local: {
|
local: {
|
||||||
price: availability.publicRate?.localPrice.pricePerStay,
|
price: availability.publicRate.localPrice.pricePerStay,
|
||||||
currency: availability.publicRate?.localPrice.currency,
|
currency: availability.publicRate.localPrice.currency,
|
||||||
},
|
},
|
||||||
euro: {
|
euro: {
|
||||||
price: availability.publicRate?.requestedPrice.pricePerStay,
|
price: availability.publicRate.requestedPrice.pricePerStay,
|
||||||
currency: availability.publicRate?.requestedPrice.currency,
|
currency: availability.publicRate.requestedPrice.currency,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,11 +109,11 @@ export default function Summary({
|
|||||||
setTotalPrice({
|
setTotalPrice({
|
||||||
local: {
|
local: {
|
||||||
price: parsePrice(room.localPrice.price),
|
price: parsePrice(room.localPrice.price),
|
||||||
currency: room.localPrice.currency!,
|
currency: room.localPrice.currency,
|
||||||
},
|
},
|
||||||
euro: {
|
euro: {
|
||||||
price: parsePrice(room.euroPrice.price),
|
price: parsePrice(room.euroPrice.price),
|
||||||
currency: room.euroPrice.currency!,
|
currency: room.euroPrice.currency,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}, [room.localPrice, room.euroPrice, setTotalPrice])
|
}, [room.localPrice, room.euroPrice, setTotalPrice])
|
||||||
|
|||||||
@@ -554,15 +554,14 @@ export const productTypePriceSchema = z.object({
|
|||||||
|
|
||||||
const productSchema = z.object({
|
const productSchema = z.object({
|
||||||
productType: z.object({
|
productType: z.object({
|
||||||
public: productTypePriceSchema.optional(),
|
public: productTypePriceSchema,
|
||||||
member: productTypePriceSchema.optional(),
|
member: productTypePriceSchema.optional(),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
const roomConfigurationSchema = z.object({
|
const roomConfigurationSchema = z.object({
|
||||||
status: z.string(),
|
status: z.string(),
|
||||||
// TODO: Remove the optional when the API change has been deployed
|
roomTypeCode: z.string(),
|
||||||
roomTypeCode: z.string().optional(),
|
|
||||||
roomType: z.string(),
|
roomType: z.string(),
|
||||||
roomsLeft: z.number(),
|
roomsLeft: z.number(),
|
||||||
features: z.array(
|
features: z.array(
|
||||||
@@ -825,17 +824,11 @@ export const apiLocationsSchema = z.object({
|
|||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
const breakfastPackagePriceSchema = z
|
const breakfastPackagePriceSchema = z.object({
|
||||||
.object({
|
currency: z.nativeEnum(CurrencyEnum),
|
||||||
currency: z.nativeEnum(CurrencyEnum),
|
price: z.string(),
|
||||||
price: z.string(),
|
totalPrice: z.string(),
|
||||||
totalPrice: z.string(),
|
})
|
||||||
})
|
|
||||||
.default({
|
|
||||||
currency: CurrencyEnum.SEK,
|
|
||||||
price: "0",
|
|
||||||
totalPrice: "0",
|
|
||||||
}) // TODO: Remove optional and default when the API change has been deployed
|
|
||||||
|
|
||||||
export const breakfastPackageSchema = z.object({
|
export const breakfastPackageSchema = z.object({
|
||||||
code: z.string(),
|
code: z.string(),
|
||||||
|
|||||||
@@ -733,9 +733,15 @@ export const hotelQueryRouter = router({
|
|||||||
|
|
||||||
const rateTypes = selectedRoom.products.find(
|
const rateTypes = selectedRoom.products.find(
|
||||||
(rate) =>
|
(rate) =>
|
||||||
rate.productType.public?.rateCode === rateCode ||
|
rate.productType.public.rateCode === rateCode ||
|
||||||
rate.productType.member?.rateCode === rateCode
|
rate.productType.member?.rateCode === rateCode
|
||||||
)?.productType
|
)
|
||||||
|
|
||||||
|
if (!rateTypes) {
|
||||||
|
console.error("No matching rate found")
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
const rates = rateTypes.productType
|
||||||
|
|
||||||
const mustBeGuaranteed =
|
const mustBeGuaranteed =
|
||||||
validateAvailabilityData.data.rateDefinitions.filter(
|
validateAvailabilityData.data.rateDefinitions.filter(
|
||||||
@@ -785,8 +791,8 @@ export const hotelQueryRouter = router({
|
|||||||
selectedRoom,
|
selectedRoom,
|
||||||
mustBeGuaranteed,
|
mustBeGuaranteed,
|
||||||
cancellationText,
|
cancellationText,
|
||||||
memberRate: rateTypes?.member,
|
memberRate: rates?.member,
|
||||||
publicRate: rateTypes?.public,
|
publicRate: rates.public,
|
||||||
bedTypes,
|
bedTypes,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ export interface BookingData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Price = {
|
type Price = {
|
||||||
price?: string
|
price: string
|
||||||
currency?: string
|
currency: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RoomsData = {
|
export type RoomsData = {
|
||||||
|
|||||||
Reference in New Issue
Block a user