/**
 * 选修课模块共享常量（消除 types.ts / elective-course-form.tsx / elective-filters.tsx 重复定义）。
 *
 * 注意：标签使用 i18n key，由组件层通过 `useTranslations("elective")` 解析。
 */
import type {
  ElectiveCourseStatus,
  ElectiveSelectionMode,
  CourseSelectionStatus,
} from "./types"

/** 课程状态 → i18n key 映射 */
export const ELECTIVE_STATUS_LABEL_KEYS: Record<ElectiveCourseStatus, string> = {
  draft: "status.draft",
  open: "status.open",
  closed: "status.closed",
  cancelled: "status.cancelled",
}

/** 课程状态 → Badge variant 映射 */
export const ELECTIVE_STATUS_BADGE_VARIANTS: Record<ElectiveCourseStatus, "default" | "secondary" | "destructive" | "outline"> = {
  draft: "secondary",
  open: "default",
  closed: "outline",
  cancelled: "destructive",
}

/** 选课模式 → i18n key 映射 */
export const SELECTION_MODE_LABEL_KEYS: Record<ElectiveSelectionMode, string> = {
  fcfs: "selectionMode.fcfs",
  lottery: "selectionMode.lottery",
}

/** 选课状态 → i18n key 映射 */
export const COURSE_SELECTION_STATUS_LABEL_KEYS: Record<CourseSelectionStatus, string> = {
  selected: "selectionStatus.selected",
  enrolled: "selectionStatus.enrolled",
  waitlist: "selectionStatus.waitlist",
  dropped: "selectionStatus.dropped",
  rejected: "selectionStatus.rejected",
}

/** 选课状态 → Badge variant 映射 */
export const COURSE_SELECTION_STATUS_BADGE_VARIANTS: Record<CourseSelectionStatus, "default" | "secondary" | "destructive" | "outline"> = {
  selected: "secondary",
  enrolled: "default",
  waitlist: "outline",
  dropped: "destructive",
  rejected: "destructive",
}

/** 类型守卫：校验字符串是否为合法的选课模式 */
export function isSelectionMode(v: string): v is ElectiveSelectionMode {
  return v === "fcfs" || v === "lottery"
}
