import { z } from 'zod'

const CATEGORIES = [
  'BOOKING', 'PICKUP', 'VEHICLE_CLEANLINESS', 'VEHICLE_CONDITION', 'STAFF_SERVICE',
  'PRICING', 'DEPOSIT', 'INSURANCE', 'DAMAGE_CLAIM', 'RETURN_PROCESS',
  'COMMUNICATION', 'ROADSIDE_ASSISTANCE', 'BILLING', 'OTHER',
] as const

const SEVERITIES = ['LEVEL_1', 'LEVEL_2', 'LEVEL_3'] as const
const STATUSES   = ['OPEN', 'INVESTIGATING', 'RESOLVED', 'CLOSED'] as const

export const createSchema = z.object({
  reservationId: z.string().optional(),
  reviewId:      z.string().optional(),
  customerId:    z.string().optional(),
  severity:      z.enum(SEVERITIES).default('LEVEL_1'),
  category:      z.enum(CATEGORIES),
  subject:       z.string().min(1),
  description:   z.string().optional(),
  assignedTo:    z.string().optional(),
})

export const updateSchema = z.object({
  status:      z.enum(STATUSES).optional(),
  severity:    z.enum(SEVERITIES).optional(),
  category:    z.enum(CATEGORIES).optional(),
  subject:     z.string().min(1).optional(),
  description: z.string().optional(),
  notes:       z.string().optional(),
  resolution:  z.string().optional(),
  assignedTo:  z.string().optional(),
})

export const listQuerySchema = z.object({
  status:   z.string().optional(),
  severity: z.string().optional(),
  category: z.string().optional(),
  page:     z.coerce.number().int().min(1).default(1),
  pageSize: z.coerce.number().int().min(1).max(100).default(20),
})

export const idParamSchema = z.object({
  id: z.string(),
})
