/**
 * Auth Context
 * Authentication context - separated for Fast Refresh compatibility
 */

import { createContext } from "react";
import type { AuthResponse } from "@/api";

export type UserRole = "admin" | "user" | string;

export interface User {
  userId?: string;
  username: string;
  role: UserRole;
  workspaceId?: string;
  workspaceName?: string;
  namespace?: string;
  defaultClusterId?: string;
  quotaCpu?: string;
  quotaMemory?: string;
  quotaGpu?: string;
  quotaGpuMemory?: string;
  permissions: string[];
  permissionVersion?: string | number;
}

export interface AuthContextType {
  token: string | null;
  user: User | null;
  isAuthenticated: boolean;
  isHydratingUser: boolean;
  login: (response: AuthResponse) => void;
  logout: () => void;
  refreshUser: () => Promise<void>;
}

export const AuthContext = createContext<AuthContextType | undefined>(undefined);
