import { z } from "zod"

const relationFieldSchema = z
    .object({ value: z.string(), label: z.string() })
    .nullable()

const inspectionFormSchema = z.object({
    customer: relationFieldSchema,
    vehicle: relationFieldSchema,
    department: relationFieldSchema,
    inspection_category: relationFieldSchema,
    employee: relationFieldSchema,
    job_card: relationFieldSchema.optional(),
    labor_rate: relationFieldSchema.optional(),
    title: z.string().min(1, "Title is required"),
    order_number: z.string().optional(),
    date: z.string().optional(),
    time: z.string().optional(),
    status: z.string().optional(),
    note: z.string().optional(),
    description: z.string().optional(),
    rate_type: z.string().optional(),
    quantity: z.coerce.number().min(0).optional(),
    rate: z.coerce.number().min(0).optional(),
    working_hours: z.coerce.number().min(0).optional(),
    labor_hours: z.coerce.number().min(0).optional(),
    tax: z.string().optional(),
    chart_of_account: z.string().optional(),
})

type InspectionFormValues = z.infer<typeof inspectionFormSchema>

export { inspectionFormSchema, relationFieldSchema }
export type { InspectionFormValues }
