Add custom commission types
This commit is contained in:
35
src/schemas/commissionCustomCard.ts
Normal file
35
src/schemas/commissionCustomCard.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import * as z from "zod/v4";
|
||||
|
||||
const rangePattern = /^\d{1,3}–\d{1,3}$/;
|
||||
|
||||
const optionField = z.object({
|
||||
optionId: z.string(),
|
||||
price: z.number().optional(),
|
||||
pricePercent: z.number().optional(),
|
||||
priceRange: z
|
||||
.string()
|
||||
.regex(rangePattern, "Format must be like '10–80'")
|
||||
.optional(),
|
||||
});
|
||||
|
||||
const extraField = z.object({
|
||||
extraId: z.string(),
|
||||
price: z.number().optional(),
|
||||
pricePercent: z.number().optional(),
|
||||
priceRange: z
|
||||
.string()
|
||||
.regex(rangePattern, "Format must be like '10–80'")
|
||||
.optional(),
|
||||
});
|
||||
|
||||
export const commissionCustomCardSchema = z.object({
|
||||
name: z.string().min(1, "Name is required. Min 1 character."),
|
||||
description: z.string().optional(),
|
||||
isVisible: z.boolean().default(true),
|
||||
isSpecialOffer: z.boolean().default(false),
|
||||
referenceImageUrl: z.string().nullable().optional(),
|
||||
options: z.array(optionField).optional(),
|
||||
extras: z.array(extraField).optional(),
|
||||
});
|
||||
|
||||
export type CommissionCustomCardValues = z.infer<typeof commissionCustomCardSchema>;
|
||||
Reference in New Issue
Block a user