import { type User } from 'navigraph/auth';
import { createContext, useContext } from 'react';
import { auth } from '../../lib/navigraph';

interface NavigraphAuthContext {
  initialized: boolean;
  user: User | null;
  signIn: typeof auth.signInWithDeviceFlow;
}

export const authContext = createContext<NavigraphAuthContext>({
  initialized: false,
  user: null,
  signIn: () => Promise.reject('Not initialized'),
});

export const useNavigraphAuth = () => {
  return useContext(authContext);
};
