Files
web/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/schema.ts
Christel Westerberg 6b08d5a113 Merged in fix/STAY-135 (pull request #3368)
Fix/STAY-135 & STAY-127

* fix: make quantity and delivery separate steps in mobile

* fix: update design for delivery step in ancillary flow

* fix: add error state for missing time

* fix: only allow points or cash payment for ancillaries

* fix: break out stepper to design system

* fix: update design of select quantity step in add ancillaries flow

* fix: add error states for quantity

* fix: handle insufficient points case

* fix: update stepper to include optional disabledMessage tooltip

* fix: handle validations

* fix: change name to camel case


Approved-by: Bianca Widstam
Approved-by: Chuma Mcphoy (We Ahead)
2025-12-18 13:31:43 +00:00

29 lines
848 B
TypeScript

import { z } from "zod"
import { nullableStringValidator } from "@scandic-hotels/common/utils/zod/stringValidator"
export const ancillaryError = {
TERMS_NOT_ACCEPTED: "TERMS_NOT_ACCEPTED",
MIN_QUANTITY_NOT_REACHED: "MIN_QUANTITY_NOT_REACHED",
} as const
export enum PaymentChoiceEnum {
Points = "points",
Card = "card",
}
export const ancillaryFormSchema = z.object({
deliveryTime: z.string(),
optionalText: z.string(),
termsAndConditions: z
.boolean()
.refine((value) => value === true, ancillaryError.TERMS_NOT_ACCEPTED),
paymentMethod: nullableStringValidator,
quantity: z.number().min(1, ancillaryError.MIN_QUANTITY_NOT_REACHED),
paymentChoice: z.nativeEnum(PaymentChoiceEnum, {
message: ancillaryError.MIN_QUANTITY_NOT_REACHED,
}),
})
export type AncillaryFormData = z.output<typeof ancillaryFormSchema>