"use client"; import { createContext, useContext, ReactNode } from "react"; import { authClient, useSession } from "@/lib/auth-client"; type AuthContextType = { session: ReturnType["data"]; isPending: boolean; error: ReturnType["error"]; signOut: () => Promise; }; const AuthContext = createContext(null); export function AuthProvider({ children }: { children: ReactNode }) { const { data: session, isPending, error } = useSession(); const handleSignOut = async () => { await authClient.signOut(); window.location.href = "/auth/sign-in"; }; return ( {children} ); } export function useAuth() { const context = useContext(AuthContext); if (!context) { throw new Error("useAuth must be used within an AuthProvider"); } return context; }