import type { DefaultSession } from "next-auth";
import type { DepartmentKey, UserRole } from "@/lib/types";

declare module "next-auth" {
  interface Session {
    user: DefaultSession["user"] & {
      id: string;
      role: UserRole;
      department?: DepartmentKey | null;
      departmentRole?: string | null;
      canElevate?: boolean;
      baseRole?: UserRole;
      baseDepartment?: DepartmentKey | null;
      baseDepartmentRole?: string | null;
      isViewingAs?: boolean;
      viewAsRole?: UserRole | null;
      viewAsDepartment?: DepartmentKey | null;
      viewAsDepartmentRole?: string | null;
    };
  }

  interface User {
    role?: UserRole;
    department?: DepartmentKey | null;
    departmentRole?: string | null;
    canElevate?: boolean;
    baseRole?: UserRole;
    baseDepartment?: DepartmentKey | null;
    baseDepartmentRole?: string | null;
    isViewingAs?: boolean;
    viewAsRole?: UserRole | null;
    viewAsDepartment?: DepartmentKey | null;
    viewAsDepartmentRole?: string | null;
  }
}

declare module "next-auth/jwt" {
  interface JWT {
    role?: UserRole;
    department?: DepartmentKey | null;
    departmentRole?: string | null;
    canElevate?: boolean;
    baseRole?: UserRole;
    baseDepartment?: DepartmentKey | null;
    baseDepartmentRole?: string | null;
    isViewingAs?: boolean;
    viewAsRole?: UserRole | null;
    viewAsDepartment?: DepartmentKey | null;
    viewAsDepartmentRole?: string | null;
  }
}
