import { IProCptItem } from './compilation';
import { IUsedCptItem } from './user';

export enum Relationship {
  ADMIN = 'admin',
  STAFF = 'staff',
  IRRELEVANT = 'irrelevant',
}

export enum MemberRole {
  ADMIN = 'admin',
  STAFF = 'staff',
}

export enum MemberStatus {
  NORMAL = 'normal',
  DISABLED = 'disabled',
  UNCONFIRMED = 'unconfirmed',
}

export interface IMember {
  userID: string;
  memberName: string;
  position: string;
  role: MemberRole;
  status: MemberStatus;
  cptList: string[];
  createProject: boolean;
  projectView: 'self' | 'all';
  editProject: 'self' | 'all';
  exportProject: 'disabled' | 'self' | 'all';
  importProject: 'disabled' | 'self' | 'all';
  shareProject: 'disabled' | 'self' | 'all';
  needResetPassword: boolean;
}

export interface IEnterprise {
  ID: string;
  members: IMember[];
  activated: boolean;
  licenceNum: number;
  proCptList: IProCptItem[];
  usedCptList: IUsedCptItem[];
  // 公司名称
  name: string;
  logo: string;
  location: string[];
  // 公司类型
  type: string;
  scale: string;
  createTime: number;
  subdomain: string;
  domain: string;
  icp: string;
  ip: string;
  logoutRule: string;
}

export enum EnterpriseLogType {
  INVITE = 'invite',
  REMOVE = 'remove',
  TRANSFER = 'transfer',
  PERMISSION = 'permission',
  ENTERPRISE_NAME = 'enterpriseName',
  ENTERPRISE_INFO = 'enterpriseInfo',
  LOGO = 'logo',
  SUBDOMAIN = 'subdomain',
  RESET_PASSWORD = 'resetPassword',
  LOGOUT_RULE = 'logoutRule',
}

export interface IEnterpriseLog {
  enterpriseID: string;
  browser: string;
  os: string;
  ip: string;
  ipInfo: string;
  userID: string;
  mobile: string;
  memberName: string;
  event: EnterpriseLogType;
  content: string;
  createTime: number;
}

export enum SystemLogType {
  CREATE = 'create',
  ENTERPRISE_NAME = 'enterpriseName',
  NEW_ADMIN = 'newAdmin',
  LICENCE = 'licence',
  ADD_CPT = 'addCpt',
  UPDATE_CPT = 'updateCpt',
  CPT_EXPIRED = 'cptExpired',
}

export interface ISystemLog {
  enterpriseID: string;
  from: 'system' | 'platform';
  event: SystemLogType;
  content: string;
  time: number;
}

export interface IMemberInfo {
  userID: string;
  userName: string;
  mobile: string;
  enterpriseID: string;
  enterpriseName: string;
}

export interface IEnterpriseSession {
  sessionID: string;
  createTime: number;
  effectiveDuration: number;
  enterpriseID: string; // 企业 ID （如果没有enterpriseID，则表示为个人版登录）
  date: number; // 日期（只包含年月日）
  userID: string;
}
