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

export interface CrmUserRoleAssignmentRecord {
  id: string;
  organizationId: string;
  userId: string;
  userName: string;
  userEmail: string;
  roleProfileId: string;
  roleProfileCode: string;
  roleProfileName: string;
  branchScopeMode: CrmRoleAssignmentScopeMode;
  branchScopeIds: string[];
  productTypeScopeMode: CrmRoleAssignmentScopeMode;
  productTypeScopeIds: string[];
  isPrimary: boolean;
  isActive: boolean;
  assignedBy: string;
  assignedAt: string;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
}

export interface CrmRoleAssignmentReferenceOption {
  id: string;
  code?: string;
  name?: string;
  label?: string;
  email?: string;
}

export interface CrmUserRoleAssignmentsResponse {
  success: boolean;
  time: string;
  message: string;
  assignments: CrmUserRoleAssignmentRecord[];
  scopeModes: CrmRoleAssignmentScopeMode[];
  roleProfiles: Array<{ id: string; code: string; name: string }>;
  users: Array<{ id: string; name: string; email: string }>;
  branches: Array<{ id: string; code: string; label: string }>;
  productTypes: Array<{ id: string; code: string; label: string }>;
}

export interface CrmUserRoleAssignmentMutationPayload {
  userId: string;
  roleProfileId: string;
  branchScopeMode: CrmRoleAssignmentScopeMode;
  branchScopeIds: string[];
  productTypeScopeMode: CrmRoleAssignmentScopeMode;
  productTypeScopeIds: string[];
  isPrimary: boolean;
  isActive: boolean;
}

export interface UpdateCrmUserRoleAssignmentPayload {
  branchScopeMode: CrmRoleAssignmentScopeMode;
  branchScopeIds: string[];
  productTypeScopeMode: CrmRoleAssignmentScopeMode;
  productTypeScopeIds: string[];
  isPrimary: boolean;
  isActive: boolean;
}
