mirror of
https://github.com/documenso/documenso.git
synced 2025-11-22 12:41:36 +10:00
fix: add missing teamId references
This commit is contained in:
31
apps/web/src/providers/team.tsx
Normal file
31
apps/web/src/providers/team.tsx
Normal file
@ -0,0 +1,31 @@
|
||||
'use client';
|
||||
|
||||
import { createContext, useContext } from 'react';
|
||||
import React from 'react';
|
||||
|
||||
import type { Team } from '@documenso/prisma/client';
|
||||
|
||||
interface TeamProviderProps {
|
||||
children: React.ReactNode;
|
||||
team: Team;
|
||||
}
|
||||
|
||||
const TeamContext = createContext<Team | null>(null);
|
||||
|
||||
export const useCurrentTeam = (): Team | null => {
|
||||
const context = useContext(TeamContext);
|
||||
|
||||
if (!context) {
|
||||
throw new Error('useCurrentTeam must be used within a TeamProvider');
|
||||
}
|
||||
|
||||
return context;
|
||||
};
|
||||
|
||||
export const useOptionalCurrentTeam = (): Team | null => {
|
||||
return useContext(TeamContext);
|
||||
};
|
||||
|
||||
export const TeamProvider = ({ children, team }: TeamProviderProps) => {
|
||||
return <TeamContext.Provider value={team}>{children}</TeamContext.Provider>;
|
||||
};
|
||||
Reference in New Issue
Block a user