import { z } from 'zod';

const ticketMessageSchema = z.object({
  sender: z.string(),
  content: z.string(),
  timestamp: z.string().optional(),
  is_staff: z.boolean().optional(),
});

export const createTicketSchema = z.object({
  subject: z.string().min(1, 'Subject is required'),
  category: z.string().optional(),
  priority: z.enum(['low', 'medium', 'high', 'urgent']).optional(),
  description: z.string().optional(),
});

export const updateTicketSchema = z.object({
  status: z.enum(['open', 'in_progress', 'resolved', 'closed']).optional(),
  priority: z.enum(['low', 'medium', 'high', 'urgent']).optional(),
  category: z.string().optional(),
  messages: z.array(ticketMessageSchema).optional(),
});

export const addTicketMessageSchema = z.object({
  content: z.string().min(1, 'Message content is required'),
  is_staff: z.boolean().optional(),
});

export type CreateTicketInput = z.infer<typeof createTicketSchema>;
export type UpdateTicketInput = z.infer<typeof updateTicketSchema>;
export type AddTicketMessageInput = z.infer<typeof addTicketMessageSchema>;
