/** Roster 共享类型与常量 */

/** 金额格式化：保留两位小数 + 千分位 */
export const fmt = (n: number) => (n || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })

/** 解聘原因映射 */
export const terminateReasonMap: Record<string, string> = {
  NEGOTIATED: '协商解除',
  FAULT: '员工过错',
  NONFAULT: '非过错解除',
  LAYOFF: '经济性裁员',
  EXPIRED: '合同到期不续签',
}

/** 详情页 Tab 类型 */
export type DetailTab = 'basic' | 'contract' | 'payslip' | 'attendance' | 'disciplinary' | 'performance' | 'termination' | 'evidence' | 'history' | 'attachments'

/** Tab 分组 */
export type TabGroup = '人事信息' | '考勤绩效' | '风险合规' | '薪酬' | '变更历史'

/** Tab 分组配置 */
export const TAB_GROUPS: { group: TabGroup; tabs: { key: DetailTab; label: string; icon: any }[] }[] = [
  {
    group: '人事信息',
    tabs: [
      { key: 'basic', label: '基本信息', icon: null },
      { key: 'contract', label: '劳动合同', icon: null },
      { key: 'attachments', label: '附件资料', icon: null },
    ],
  },
  {
    group: '薪酬',
    tabs: [
      { key: 'payslip', label: '薪酬社保', icon: null },
    ],
  },
  {
    group: '考勤绩效',
    tabs: [
      { key: 'attendance', label: '考勤培训', icon: null },
      { key: 'performance', label: '绩效考核', icon: null },
    ],
  },
  {
    group: '风险合规',
    tabs: [
      { key: 'disciplinary', label: '违纪记录', icon: null },
      { key: 'termination', label: '离职/解聘', icon: null },
      { key: 'evidence', label: '证据链', icon: null },
    ],
  },
  {
    group: '变更历史',
    tabs: [
      { key: 'history', label: '变更历史', icon: null },
    ],
  },
]

/** Tab 计数字段映射 */
export const TAB_COUNT_KEYS: Record<string, string> = {
  contract: 'contracts',
  payslip: 'payslips',
  attendance: 'attendanceRecords',
  disciplinary: 'disciplinaryRecords',
  performance: 'performanceRecords',
  termination: 'terminations',
  attachments: 'attachments',
}
