import React, { createContext, useContext } from 'react';
import { useAuth as useAuthHook } from './hooks';

const AuthContext = createContext<any>(null);

export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
  const auth = useAuthHook();
  return <AuthContext.Provider value={auth}>{children}</AuthContext.Provider>;
};

// Ce hook permettra d'accéder à l'auth n'importe où
export function useAuthContext() {
  return useContext(AuthContext);
}