/* eslint-disable import/prefer-default-export */
export enum SocketEvent {
  JOIN = 'join',
  LEAVE = 'leave',
  NOTIFY = 'notify',
  // 正在查看项目有用户进入
  VIEW_PROJECT_ENTER = 'viewProjectEnter',
  // 正在查看项目有用户离开
  VIEW_PROJECT_LEAVE = 'viewProjectLeave',
}

export enum MessageName {
  INVITE = 'invite',
  JOIN = 'join',
  REMOVE_FROM_ENTERPRISE = 'removeFromEnterprise',
  ALL_RESET_PASSWORD = 'allResetPassword',
  TRANSFER_DATA = 'transferData',
  ACCEPT_TRANSFER_DATA = 'acceptTransferData',
  TRANSFER_ADMIN = 'transferAdmin',
  SHARE_PROJECT = 'shareProject',
  SHARE_LIB = 'shareLib',
  UPDATE_SHARE_PROJECT = 'updateShareProject',
  CANCEL_SHARE_PROJECT = 'cancelShareProject',
  CANCEL_SHARE_LIB = 'cancelShareLib',
  REPEAT_LOGIN = 'repeatLogin',
}

export interface ISocketDataType {
  title: string;
  message: string;

  [key: string]: any;
}

export interface ISocketData {
  // success warning info error, 空字符串或者 undefined 代表普通的消息
  type?: string;
  // 房间号
  rooms: string[];
  // 消息的名称，标识这个消息是什么消息，如 invite 表示邀请加入企业
  name: MessageName;
  // 数据
  data: ISocketDataType;
}

export interface IMessage {
  ID: string;
  userID: string;
  title: string;
  content: string;
  name: MessageName;
  data?: any;
  tags: string[];
  unread: boolean;
  removable: boolean;
  createTime: number;
}

// 平台信息
interface IProcess {
  processID: string;
  approvalOpinon?: string;
  approvalChangePrice: number;
  approvaledPrice: number;
}

export enum TypeMessageData {
  APPROVAL = 'approval',
  SYSTEM = 'system',
}

export interface IMessageContent {
  stepName: string;
  approvalComments: string;
  addition: string;
  reduction: string;
  conclusion: string;
}

export interface ISimpleMessageData {
  businessID?: string;
  title: string;
  userID: string;
  status?: string;
  type?: TypeMessageData;
  content?: IMessageContent;
}

export interface IMessageData extends ISimpleMessageData {
  // businessID: string;
  // userID: string;
  ID: string;
  createTime: number;
  // status: string;
  read?: boolean;
  // type: TypeMessageData;
  // title: string;
  isShowProcess?: boolean;
  userName: string;
  phone?: string;
  process?: IProcess;
  auditData?: {
    name: string;
    account: string;
    institutionName: string;
  };
  // content?: string;
}

export enum IMessageStatus {
  /** 未审批 */
  UNAPPROVED = 'unapproved',
  /** 审批完成 */
  APPROVALCOMPLETED = 'approvalCompleted',
  /** 退回 */
  RETURN = 'return',
  /** 业务被删除 */
  DELETE = 'delete',
  /* 加签 */
  APOSTILLE = 'apostille',
  /* 账号相关 */
  ACCOUNT = 'account',
}
