// 用户管理相关类型定义

export interface User {
  id: string;
  username: string;
  email: string;
  fullName: string | null;
  phone: string | null;
  isActive: boolean;
  isSuperuser: boolean;
  isVerified: boolean;
  createdAt: string;
  updatedAt: string;
  lastLoginAt: string | null;
  avatarUrl: string | null;
  bio: string | null;
  displayName: string | null;
  departmentId: string | null;
  departmentName: string | null;
  scope: string;
  companyName: string | null;
  tenantId: string;
}

// 为了兼容现有代码，保留一些映射属性
export interface UserWithLegacyFields extends User {
  // 向后兼容的属性
  name: string;
  phone: string;
  enterpriseId?: string;
  enterpriseName?: string;
  userType: UserType;
  status: UserStatus;
  lastLoginTime?: string;
  roleIds: string[];
  roles?: string[];
}

export type UserType = 'super_admin' | 'enterprise_admin' | 'employee';
export type UserStatus = 'active' | 'inactive' | 'frozen';

export interface Enterprise {
  id: string;
  name: string;
}

// 统计数据
export interface UserManagementStats {
  label: string;
  value: number;
  color: string;
  bg: string;
}

// 筛选条件
export interface UserFilters {
  searchKeyword: string;
  statusFilter: string;
  typeFilter: string;
}

// API响应数据类型
export interface UsersApiResponse {
  data: User[];
  total: number;
  page: number;
  size: number;
  total_pages: number;
  has_next: boolean;
  has_prev: boolean;
}

// 分页状态
export interface PaginationState {
  page: number;
  size: number;
  total: number;
  totalPages: number;
  hasNext: boolean;
  hasPrev: boolean;
}

// API查询参数
export interface UsersQueryParams {
  search?: string;
  is_active?: boolean;
  page?: number;
  size?: number;
  order_by?: string;
  sort_order?: 'asc' | 'desc';
}

// 表单数据
export interface UserFormData {
  username?: string;
  name?: string;
  phone?: string;
  email?: string;
  userType?: UserType;
  status?: UserStatus;
  enterpriseId?: string;
  enterpriseName?: string;
  roleIds?: string[];
}