// src/contexts/AuthContext.ts
import { createContext } from 'react';
import type { User, UserProfile } from '../types';

/**
 * Defines the possible authentication states for a user session.
 * - `Determining...`: The initial state while checking for a token.
 * - `SIGNED_OUT`: No user is active.
 * - `AUTHENTICATED`: The user has successfully logged in.
 */
export type AuthStatus = 'Determining...' | 'SIGNED_OUT' | 'AUTHENTICATED';

export interface AuthContextType {
  user: User | null;
  profile: UserProfile | null;
  authStatus: AuthStatus;
  isLoading: boolean;
  login: (user: User, token: string) => Promise<void>;
  logout: () => void;
  updateProfile: (updatedProfileData: Partial<UserProfile>) => void;
}

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