import { z } from "zod"

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

export const taskFormSchema = z.object({
    subject: z.string().min(1, "Subject is required").max(255, "Subject cannot exceed 255 characters"),
    description: z.string().optional(),
    task_type: relationFieldSchema.refine((val) => !!val?.value, "Task type is required"),
    task_section: relationFieldSchema.refine((val) => !!val?.value, "Task section is required"),
    owner: relationFieldSchema,
    department: relationFieldSchema,
    priority: z.string().optional(),
    due_date: z.string().optional(),
    status: z.string().optional(),
    job_card: relationFieldSchema,
})

export type TaskFormValues = z.infer<typeof taskFormSchema>
