Add custom YCH typs for commission page

This commit is contained in:
2026-02-01 16:08:08 +01:00
parent 1940867519
commit aa95635e3e
6 changed files with 364 additions and 14 deletions

View File

@ -4,6 +4,7 @@ import { z } from "zod";
const submitPayloadSchema = z.object({
typeId: z.string().optional().nullable(),
customCardId: z.string().optional().nullable(),
optionId: z.string().optional().nullable(),
extraIds: z.array(z.string()).default([]),
@ -11,6 +12,23 @@ const submitPayloadSchema = z.object({
customerEmail: z.string().email(),
customerSocials: z.string().optional().nullable(),
message: z.string().min(1),
}).superRefine((data, ctx) => {
const hasType = Boolean(data.typeId);
const hasCustom = Boolean(data.customCardId);
if (!hasType && !hasCustom) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ["typeId"],
message: "Missing commission type or custom card",
});
}
if (hasType && hasCustom) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ["typeId"],
message: "Only one of typeId or customCardId is allowed",
});
}
});
export type SubmitCommissionPayload = z.infer<typeof submitPayloadSchema>;