23 lines
589 B
TypeScript
23 lines
589 B
TypeScript
"use client";
|
|
|
|
import { createContext, useContext } from "react";
|
|
import useAuth from "@/features/auth/hooks/use-auth";
|
|
|
|
const AuthContext = createContext<ReturnType<typeof useAuth> | null>(null);
|
|
|
|
type AuthProviderProps = {
|
|
children: React.ReactNode;
|
|
};
|
|
|
|
export function AuthProvider({ children }: AuthProviderProps) {
|
|
const auth = useAuth();
|
|
return <AuthContext.Provider value={auth}>{children}</AuthContext.Provider>;
|
|
}
|
|
|
|
export function useAuthContext() {
|
|
const ctx = useContext(AuthContext);
|
|
if (!ctx) throw new Error("AuthProvider is missing");
|
|
return ctx;
|
|
}
|
|
|