import * as z from 'zod';

export const trainingMatrixSchema = z
  .object({
    departmentId: z.string().optional(),
    positionId: z.string().optional(),
    courseId: z.string().min(1, 'Please select a course'),
    isRequired: z.boolean(),
    renewalPeriodMonths: z.number().int().min(0).optional(),
    note: z.string().trim().optional()
  })
  .refine((value) => Boolean(value.departmentId || value.positionId), {
    message: 'Please select a department or position',
    path: ['departmentId']
  });

export type TrainingMatrixFormValues = {
  departmentId?: string;
  positionId?: string;
  courseId: string;
  isRequired: boolean;
  renewalPeriodMonths?: number | undefined;
  note?: string;
};
