export function resolveAdminRedirectPath(user: { role?: string; roles?: { code: string }[] | string[]; permissions?: string[]; user_type?: string }): string {
  const roles = user.roles ?? (user.role ? [{ code: user.role }] : []);
  const roleCodes = roles.map((r: any) => typeof r === 'string' ? r : r.code) as string[];
  const permissions = user.permissions ?? [];

  if (roleCodes.includes("super_admin")) return "/";
  if (roleCodes.includes("compliance_officer")) return "/kyc";
  if (permissions.includes("view_dashboard")) return "/";
  if (permissions.includes("manage_kyc")) return "/kyc";
  if (permissions.includes("manage_customers")) return "/customers";
  if (permissions.includes("manage_orders")) return "/orders";
  if (permissions.includes("manage_inventory")) return "/inventory";
  if (permissions.includes("view_audit_logs")) return "/audit-logs";

  return "/";
}