/**
 * L-5 在线请假流程类型定义。
 *
 * 状态机：pending → approved/rejected；pending/approved 可被 requester 撤销为 cancelled。
 * 审批通过后异步同步考勤（写入 attendance_records with status='excused'）。
 */

/** 请假类型 */
export type LeaveType = "sick" | "personal" | "family" | "other"

/** 请假状态 */
export type LeaveStatus = "pending" | "approved" | "rejected" | "cancelled"

/** 请假申请完整记录（对应 leave_requests 表的展示形态） */
export interface LeaveRequest {
  id: string
  studentId: string
  requesterId: string
  classId: string
  leaveType: LeaveType
  startDate: string
  endDate: string
  reason: string
  status: LeaveStatus
  reviewerId: string | null
  reviewComment: string | null
  reviewedAt: string | null
  attendanceSynced: boolean
  createdAt: string
  updatedAt: string
}

/** 请假列表项（带学生/班级/提交人姓名，便于列表渲染） */
export interface LeaveRequestListItem extends LeaveRequest {
  studentName: string
  className: string
  requesterName: string
  reviewerName: string | null
}

/** 请假审批操作输入 */
export interface LeaveReviewInput {
  status: "approved" | "rejected"
  reviewComment?: string
}

/** 请假查询参数 */
export interface LeaveQueryParams {
  status?: LeaveStatus
  classId?: string
  studentId?: string
  page?: number
  pageSize?: number
}

/** 分页结果 */
export interface PaginatedLeaveResult {
  items: LeaveRequestListItem[]
  total: number
  page: number
  pageSize: number
  totalPages: number
}
