import { z } from "zod"

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

const creditNoteFormSchema = z.object({
    // ── Required fields ──
    subject: z.string().min(1, "Subject is required"),

    // ── Relations ──
    customer: relationFieldSchema,
    department: relationFieldSchema,

    // ── Optional fields ──
    date: z.string().optional(),
    status: z.string().optional(),
    notes: z.string().optional(),
})

type CreditNoteFormValues = z.infer<typeof creditNoteFormSchema>

export { creditNoteFormSchema, relationFieldSchema }
export type { CreditNoteFormValues }
