Feat/SW-1997 tracking gla my stay ancillaries * feat(SW-1996): tracking gla my stay * feat(SW-1996): update gla tracking * feat(SW-1996): fix comment * feat(SW-1997): add tracking for gla my stay and ancillaries * feat(SW-1997): rebase master * feat(SW-1997): fix duplicate import * feat(SW-1997): add hotelId and category for ancillaries, and add more tracking * feat(SW-1997): remove commments and fix spelling mistake * feat(SW-1997): if addAncillary failed, but guarantee is successful, default to card in booking Approved-by: Niclas Edenvin
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { z } from "zod"
|
|
|
|
import { nullableStringValidator } from "@/utils/zod/stringValidator"
|
|
|
|
const quantitySchemaWithoutRefine = z.object({
|
|
quantityWithPoints: z.number().nullable(),
|
|
quantityWithCard: z.number().nullable(),
|
|
})
|
|
|
|
export const quantitySchema = z
|
|
.object({})
|
|
.merge(quantitySchemaWithoutRefine)
|
|
.refine(
|
|
(data) =>
|
|
(data.quantityWithPoints ?? 0) > 0 || (data.quantityWithCard ?? 0) > 0,
|
|
{
|
|
message: "You must select at least one quantity",
|
|
path: ["quantityWithCard"],
|
|
}
|
|
)
|
|
|
|
export const ancillaryFormSchema = z
|
|
.object({
|
|
deliveryTime: z.string(),
|
|
optionalText: z.string(),
|
|
termsAndConditions: z.boolean(),
|
|
paymentMethod: nullableStringValidator,
|
|
})
|
|
.merge(quantitySchemaWithoutRefine)
|
|
.refine(
|
|
(data) =>
|
|
(data.quantityWithPoints ?? 0) > 0 || (data.quantityWithCard ?? 0) > 0,
|
|
{
|
|
message: "You must select at least one quantity",
|
|
path: ["quantityWithCard"],
|
|
}
|
|
)
|
|
|
|
export type AncillaryQuantityFormData = z.output<
|
|
typeof quantitySchemaWithoutRefine
|
|
>
|
|
export type AncillaryFormData = z.output<typeof ancillaryFormSchema>
|