40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import { z } from "zod"
|
|
|
|
const relationFieldSchema = z
|
|
.object({ value: z.string(), label: z.string() })
|
|
.nullable()
|
|
|
|
const estimateFormSchema = z.object({
|
|
// ── Required fields ──
|
|
title: z.string().min(1, "Title is required"),
|
|
|
|
// ── Relations ──
|
|
customer: relationFieldSchema,
|
|
vehicle: relationFieldSchema,
|
|
department: relationFieldSchema,
|
|
|
|
// ── Optional fields ──
|
|
estimate_number: z.string().optional(),
|
|
date: z.string().optional(),
|
|
has_insurance: z.boolean().default(false),
|
|
|
|
// ── Remarks (array of strings) ──
|
|
remarks: z.array(z.string()).optional(),
|
|
|
|
// ── Labels ──
|
|
labels: z
|
|
.array(
|
|
z.object({
|
|
id: z.number(),
|
|
title: z.string(),
|
|
color_code: z.string(),
|
|
}),
|
|
)
|
|
.optional(),
|
|
})
|
|
|
|
type EstimateFormValues = z.infer<typeof estimateFormSchema>
|
|
|
|
export { estimateFormSchema, relationFieldSchema }
|
|
export type { EstimateFormValues }
|