fix: make sure calculations in booking flow are correct
This commit is contained in:
committed by
Michael Zetterberg
parent
3e0f503314
commit
a222ecfc5c
@@ -56,7 +56,10 @@ export const breakfastPackageSchema = z.object({
|
||||
description: z.string(),
|
||||
localPrice: packagePriceSchema,
|
||||
requestedPrice: packagePriceSchema,
|
||||
packageType: z.literal(PackageTypeEnum.BreakfastAdult),
|
||||
packageType: z.enum([
|
||||
PackageTypeEnum.BreakfastAdult,
|
||||
PackageTypeEnum.BreakfastChildren,
|
||||
]),
|
||||
})
|
||||
|
||||
export const ancillaryPackageSchema = z.object({
|
||||
|
||||
@@ -8,16 +8,16 @@ import {
|
||||
} from "../productTypePrice"
|
||||
import { rateDefinitionSchema } from "./rateDefinition"
|
||||
|
||||
import { RateEnum } from "@/types/enums/rate"
|
||||
|
||||
const baseProductSchema = z.object({
|
||||
// transform empty string to undefined
|
||||
bookingCode: z
|
||||
.string()
|
||||
.optional()
|
||||
.transform((val) => val),
|
||||
// Is breakfast included on product
|
||||
breakfastIncluded: z.boolean().default(false),
|
||||
// Used to set the rate that we use to chose titles etc.
|
||||
rate: z.enum(["change", "flex", "save"]).default("save"),
|
||||
rate: z.nativeEnum(RateEnum).default(RateEnum.save),
|
||||
rateDefinition: rateDefinitionSchema.optional().transform((val) =>
|
||||
val
|
||||
? val
|
||||
@@ -42,7 +42,6 @@ const baseProductSchema = z.object({
|
||||
function mapBaseProduct(baseProduct: typeof baseProductSchema._type) {
|
||||
return {
|
||||
bookingCode: baseProduct.bookingCode,
|
||||
breakfastIncluded: baseProduct.breakfastIncluded,
|
||||
rate: baseProduct.rate,
|
||||
rateDefinition: baseProduct.rateDefinition,
|
||||
rateDefinitionMember: baseProduct.rateDefinitionMember,
|
||||
@@ -97,14 +96,12 @@ export const redemptionsProduct = z
|
||||
data.map(
|
||||
({
|
||||
bookingCode,
|
||||
breakfastIncluded,
|
||||
rate,
|
||||
rateDefinition,
|
||||
rateDefinitionMember,
|
||||
...redemption
|
||||
}) => ({
|
||||
bookingCode,
|
||||
breakfastIncluded,
|
||||
rate,
|
||||
rateDefinition,
|
||||
rateDefinitionMember,
|
||||
|
||||
Reference in New Issue
Block a user