import type {
  CrmApprovalAuthority,
  CrmOwnershipScope,
  CrmScopeMode,
  Permission
} from '@/lib/auth/rbac';

export interface CrmRoleProfileRecord {
  id: string;
  organizationId: string;
  code: string;
  name: string;
  description: string | null;
  permissions: Permission[];
  branchScopeMode: CrmScopeMode;
  productScopeMode: CrmScopeMode;
  ownershipScope: CrmOwnershipScope;
  approvalAuthority: CrmApprovalAuthority;
  isSystem: boolean;
  isActive: boolean;
  createdAt: string;
  updatedAt: string;
}

export interface PermissionGroupDto {
  key: string;
  label: string;
  permissions: Array<{
    key: Permission;
    label: string;
  }>;
}

export interface CrmRoleProfilesResponse {
  success: boolean;
  time: string;
  message: string;
  roles: CrmRoleProfileRecord[];
  permissionGroups: PermissionGroupDto[];
}

export interface UpdateCrmRoleProfilePayload {
  name: string;
  description?: string | null;
  permissions: Permission[];
  branchScopeMode: CrmScopeMode;
  productScopeMode: CrmScopeMode;
  ownershipScope: CrmOwnershipScope;
  approvalAuthority: CrmApprovalAuthority;
  isActive: boolean;
}

export interface CloneCrmRoleProfilePayload {
  code: string;
  name: string;
  description?: string | null;
}
