import { z } from 'zod'

export const ticketStatusSchema = z.enum(['open', 'processing', 'resolved', 'closed'])
export const ticketPrioritySchema = z.enum(['low', 'normal', 'high', 'urgent'])
export const ticketTypeSchema = z.enum(['system', 'application'])

export const ticketSchema = z.object({
  id: z.union([z.string(), z.number()]),
  title: z.string(),
  content: z.string(),
  status: ticketStatusSchema,
  priority: ticketPrioritySchema,
  type: ticketTypeSchema,
  application_id: z.union([z.string(), z.number()]).optional().nullable(),
  app_name: z.string().optional().nullable(),
  user_id: z.union([z.string(), z.number()]),
  user_name: z.string().optional().nullable(),
  images: z.array(z.string()).optional().default([]),
  created_at: z.string(),
  updated_at: z.string().optional().nullable(),
})

export type Ticket = z.infer<typeof ticketSchema>
