import type { BusinessRole } from '@/lib/auth/rbac';

export interface UserOrganization {
  id: string;
  name: string;
  role: 'admin' | 'user';
}

export interface UserMembership {
  organizationId: string;
  organizationName: string;
  membershipRole: 'admin' | 'user';
  businessRole: BusinessRole;
}

export interface User {
  id: string;
  name: string;
  email: string;
  systemRole: 'super_admin' | 'user';
  activeMembershipRole: 'admin' | 'user' | null;
  activeOrganizationId: string | null;
  organizations: UserOrganization[];
  memberships: UserMembership[];
}

export type UserFilters = {
  page?: number;
  limit?: number;
  roles?: string;
  search?: string;
  sort?: string;
};

export type UsersResponse = {
  success: boolean;
  time: string;
  message: string;
  total_users: number;
  offset: number;
  limit: number;
  users: User[];
};

export type UserMutationPayload = {
  name: string;
  email: string;
  password?: string;
  systemRole: 'super_admin' | 'user';
  memberships: Array<{
    organizationId: string;
    membershipRole: 'admin' | 'user';
    businessRole: BusinessRole;
  }>;
};
