import type { CustomerRecord } from '../types';

export type RiskTagCategory = '法务' | '财务' | '运维' | '风控';

export type RiskLevel = '低' | '中' | '高' | '极高';

export type RiskTagLifecycleStatus =
  | '生效中'
  | '待审批'
  | '待确认'
  | '已驳回'
  | '已过期'
  | '已移除';

export type RiskTagAction =
  | '新增'
  | '移除'
  | '变更'
  | '提交审批'
  | '审批通过'
  | '审批驳回'
  | '批量打标';

export interface RiskTagAttachment {
  id: string;
  name: string;
  size: string;
  uploadedAt: string;
}

export interface CustomerRiskTag {
  id: string;
  customerId: string;
  tagName: string;
  tagType: RiskTagCategory;
  riskLevel: RiskLevel;
  reason: string;
  effectiveFrom: string;
  effectiveTo: string;
  attachments: RiskTagAttachment[];
  status: RiskTagLifecycleStatus;
  operator: string;
  operatorRole: UserRole;
  approver?: string;
  approvedAt?: string;
  rejectReason?: string;
  createdAt: string;
  updatedAt: string;
}

export interface RiskTagOperationLog {
  id: string;
  customerId: string;
  customerName: string;
  tagId?: string;
  tagName: string;
  action: RiskTagAction;
  detail: string;
  operator: string;
  operatorRole: UserRole;
  createdAt: string;
}

export interface RiskTagApplyForm {
  tagName: string;
  tagType: RiskTagCategory;
  riskLevel: RiskLevel;
  reason: string;
  effectiveFrom: string;
  effectiveTo: string;
  attachments: RiskTagAttachment[];
}

export const EMPTY_RISK_TAG_FORM: RiskTagApplyForm = {
  tagName: '',
  tagType: '风控',
  riskLevel: '中',
  reason: '',
  effectiveFrom: '',
  effectiveTo: '',
  attachments: [],
};

export type UserRole = 'finance' | 'legal' | 'risk' | 'ops' | 'sales' | 'admin';

export interface MockUser {
  name: string;
  role: UserRole;
  department: string;
}

export type RiskTagsByCustomer = Record<string, CustomerRiskTag[]>;

export interface RiskTagContext {
  records: CustomerRecord[];
  riskTagsByCustomer: RiskTagsByCustomer;
  operationLogs: RiskTagOperationLog[];
}
