Files
documenso/packages/email/providers/branding.tsx
2025-02-13 14:10:38 +11:00

43 lines
999 B
TypeScript

import { createContext, useContext } from 'react';
type BrandingContextValue = {
brandingEnabled: boolean;
brandingUrl: string;
brandingLogo: string;
brandingCompanyDetails: string;
brandingHidePoweredBy: boolean;
};
const BrandingContext = createContext<BrandingContextValue | undefined>(undefined);
const defaultBrandingContextValue: BrandingContextValue = {
brandingEnabled: false,
brandingUrl: '',
brandingLogo: '',
brandingCompanyDetails: '',
brandingHidePoweredBy: false,
};
export const BrandingProvider = (props: {
branding?: BrandingContextValue;
children: React.ReactNode;
}) => {
return (
<BrandingContext.Provider value={props.branding ?? defaultBrandingContextValue}>
{props.children}
</BrandingContext.Provider>
);
};
export const useBranding = () => {
const ctx = useContext(BrandingContext);
if (!ctx) {
throw new Error('Branding context not found');
}
return ctx;
};
export type BrandingSettings = BrandingContextValue;