This commit is contained in:
Julien Froidefond
2025-08-20 15:43:24 +02:00
commit 09d2c5cbe1
100 changed files with 12494 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
"use client";
import { createContext, useContext, useState, ReactNode } from "react";
interface UserInfo {
firstName: string;
lastName: string;
teamName: string;
}
interface UserContextType {
userInfo: UserInfo | null;
setUserInfo: (userInfo: UserInfo | null) => void;
}
const UserContext = createContext<UserContextType | undefined>(undefined);
export function UserProvider({ children }: { children: ReactNode }) {
const [userInfo, setUserInfo] = useState<UserInfo | null>(null);
return (
<UserContext.Provider value={{ userInfo, setUserInfo }}>
{children}
</UserContext.Provider>
);
}
export function useUser() {
const context = useContext(UserContext);
if (context === undefined) {
throw new Error("useUser must be used within a UserProvider");
}
return context;
}