import { z } from 'zod';

export const createActionItemSchema = z.object({
  title: z.string().min(1, 'Title is required').max(200),
  description: z.string().max(2000).optional(),
  agendaId: z.string().optional(),
  assigneeUserId: z.string().optional(),
  dueDate: z.string().datetime().optional(),
  priority: z.enum(['low', 'normal', 'high', 'urgent']).optional(),
});

export const updateActionItemSchema = z.object({
  title: z.string().min(1).max(200).optional(),
  description: z.string().max(2000).nullable().optional(),
  assigneeUserId: z.string().nullable().optional(),
  dueDate: z.string().datetime().nullable().optional(),
  status: z.enum(['open', 'in_progress', 'done', 'blocked']).optional(),
  priority: z.enum(['low', 'normal', 'high', 'urgent']).optional(),
});

export const listActionItemsSchema = z.object({
  page: z.coerce.number().int().positive().default(1),
  limit: z.coerce.number().int().positive().max(100).default(20),
  search: z.string().optional(),
  status: z.enum(['open', 'in_progress', 'done', 'blocked']).optional(),
  assigneeUserId: z.string().optional(),
  overdue: z.preprocess((val) => val === 'true' || val === true, z.boolean().optional()),
});

export type CreateActionItemInput = z.infer<typeof createActionItemSchema>;
export type UpdateActionItemInput = z.infer<typeof updateActionItemSchema>;
export type ListActionItemsInput = z.infer<typeof listActionItemsSchema>;
