mirror of
https://github.com/documenso/documenso.git
synced 2026-07-24 00:43:40 +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
997 B
TypeScript
31 lines
997 B
TypeScript
import type { OrganisationSession } from '@documenso/trpc/server/organisation-router/get-organisation-session.types';
|
|
import type React from 'react';
|
|
import { createContext, useContext } from 'react';
|
|
|
|
type OrganisationProviderValue = OrganisationSession;
|
|
|
|
interface OrganisationProviderProps {
|
|
children: React.ReactNode;
|
|
organisation: OrganisationProviderValue | null;
|
|
}
|
|
|
|
const OrganisationContext = createContext<OrganisationProviderValue | null>(null);
|
|
|
|
export const useCurrentOrganisation = () => {
|
|
const context = useContext(OrganisationContext);
|
|
|
|
if (!context) {
|
|
throw new Error('useCurrentOrganisation must be used within a OrganisationProvider');
|
|
}
|
|
|
|
return context;
|
|
};
|
|
|
|
export const useOptionalCurrentOrganisation = () => {
|
|
return useContext(OrganisationContext);
|
|
};
|
|
|
|
export const OrganisationProvider = ({ children, organisation }: OrganisationProviderProps) => {
|
|
return <OrganisationContext.Provider value={organisation}>{children}</OrganisationContext.Provider>;
|
|
};
|