import { z } from "zod"

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

const purchaseOrderFormSchema = z.object({
    // ── Relations ──
    vendor: relationFieldSchema,
    job_card: relationFieldSchema,
    department: relationFieldSchema,

    // ── Basic info ──
    title: z.string().min(1, "Title is required"),
    order_date: z.string().optional(),
    delivery_date: z.string().optional(),
    notes: z.string().optional(),
})

type PurchaseOrderFormValues = z.infer<typeof purchaseOrderFormSchema>

export { purchaseOrderFormSchema, relationFieldSchema }
export type { PurchaseOrderFormValues }
