import { z } from "zod"

export const LeaveTypeEnum = z.enum(["sick", "personal", "family", "other"])

export const LeaveStatusEnum = z.enum([
  "pending",
  "approved",
  "rejected",
  "cancelled",
])

/** 创建请假申请 Schema */
export const CreateLeaveRequestSchema = z
  .object({
    studentId: z.string().min(1),
    classId: z.string().min(1),
    leaveType: LeaveTypeEnum,
    startDate: z.string().min(1),
    endDate: z.string().min(1),
    reason: z.string().min(1).max(500),
  })
  .refine((data) => data.endDate >= data.startDate, {
    message: "endDate must be on or after startDate",
    path: ["endDate"],
  })

export type CreateLeaveRequestInput = z.infer<typeof CreateLeaveRequestSchema>

/** 审批请假申请 Schema */
export const ReviewLeaveRequestSchema = z.object({
  status: z.enum(["approved", "rejected"]),
  reviewComment: z.string().max(500).optional(),
})

export type ReviewLeaveRequestInput = z.infer<typeof ReviewLeaveRequestSchema>
