'use client';

import React, { createContext, useContext } from 'react';
import { SessionProvider } from 'next-auth/react';
import { useAuth } from '@/hooks/useAuth';

const AuthContext = createContext<any>(null);

function AuthInner({ children }: { children: React.ReactNode }) {
    const auth = useAuth();
    return <AuthContext.Provider value={auth}>{children}</AuthContext.Provider>;
}

export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
    return (
        <SessionProvider>
            <AuthInner>{children}</AuthInner>
        </SessionProvider>
    );
};

export function useAuthContext() {
    return useContext(AuthContext);
}
