add team management (#131)

* add team management

* add more team management

* add join team page
This commit is contained in:
KM Koushik
2025-03-26 22:02:49 +11:00
committed by GitHub
parent f8113e64b5
commit 1ed5c8009f
26 changed files with 1348 additions and 13 deletions

View File

@@ -18,6 +18,8 @@ interface TeamContextType {
currentTeam: Team | null;
teams: Team[];
isLoading: boolean;
currentRole: "ADMIN" | "MEMBER";
currentIsAdmin: boolean;
}
const TeamContext = createContext<TeamContextType | undefined>(undefined);
@@ -25,10 +27,14 @@ const TeamContext = createContext<TeamContextType | undefined>(undefined);
export function TeamProvider({ children }: { children: React.ReactNode }) {
const { data: teams, status } = api.team.getTeams.useQuery();
const currentTeam = teams?.[0] ?? null;
const value = {
currentTeam: teams?.[0] ?? null,
currentTeam,
teams: teams || [],
isLoading: status === "pending",
currentRole: currentTeam?.teamUsers[0]?.role ?? "MEMBER",
currentIsAdmin: currentTeam?.teamUsers[0]?.role === "ADMIN",
};
return <TeamContext.Provider value={value}>{children}</TeamContext.Provider>;