export interface JinshujuEntryRow {
  serialNumber: number;
  name: string;
  phone: string | null;
  suggestedStudent: {
    id: number;
    name: string;
    phone: string | null;
    studentNo: string | null;
  } | null;
}

export interface StudentOption {
  id: number;
  name: string;
  phone: string | null;
  studentNo: string | null;
}

export interface PreviewResponse {
  success: boolean;
  entries: JinshujuEntryRow[];
  students: StudentOption[];
}

export interface MatchRule {
  id: number;
  name: string;
  formToken: string;
  mappings: Record<string, string>;
  createdAt: string;
}

export interface JinshujuFormField {
  key: string;
  label: string;
  type: string;
}

export type MatchDecision =
  | { action: 'match'; matchStudentId: number }
  | { action: 'create'; createName: string; createPhone: string }
  | { action: 'skip' };

export const ROW_HEIGHT = 72;
export const LEFT_WIDTH = 260;
export const GAP = 80;

export const STUDENT_FIELDS = [
  { key: 'name', label: '姓名' },
  { key: 'phone', label: '手机号' },
  { key: 'idNumber', label: '身份证号' },
  { key: 'gender', label: '性别' },
  { key: 'ethnicity', label: '民族' },
  { key: 'emergencyContact', label: '紧急联系人' },
  { key: 'emergencyPhone', label: '紧急联系电话' },
  { key: 'studentNo', label: '学号' },
];
