mirror of
https://github.com/documenso/documenso.git
synced 2026-07-24 17:04:12 +10:00
138d663c25
Merge origin/main into feat/external-2fa-codes. Resolve formatting conflicts caused by biome rollout; preserve both feature streams: PR's external 2FA token + signing-session 2FA proof additions plus main's RateLimit/RecipientExpired/signingReminders/date-auto-insert. In complete-document-with-token.ts, drop the duplicate early field-fetching block introduced when main moved that logic later with date auto-insert support; keep the EXTERNAL_TWO_FACTOR_AUTH check using derivedRecipientActionAuth.
31 lines
837 B
TypeScript
31 lines
837 B
TypeScript
import type { TeamSession } from '@documenso/trpc/server/organisation-router/get-organisation-session.types';
|
|
import type React from 'react';
|
|
import { createContext, useContext } from 'react';
|
|
|
|
type TeamProviderValue = TeamSession;
|
|
|
|
interface TeamProviderProps {
|
|
children: React.ReactNode;
|
|
team: TeamProviderValue | null;
|
|
}
|
|
|
|
const TeamContext = createContext<TeamProviderValue | null>(null);
|
|
|
|
export const useCurrentTeam = () => {
|
|
const context = useContext(TeamContext);
|
|
|
|
if (!context) {
|
|
throw new Error('useCurrentTeam must be used within a TeamProvider');
|
|
}
|
|
|
|
return context;
|
|
};
|
|
|
|
export const useOptionalCurrentTeam = () => {
|
|
return useContext(TeamContext);
|
|
};
|
|
|
|
export const TeamProvider = ({ children, team }: TeamProviderProps) => {
|
|
return <TeamContext.Provider value={team}>{children}</TeamContext.Provider>;
|
|
};
|