mirror of
https://github.com/documenso/documenso.git
synced 2025-11-18 10:42:01 +10:00
Merge branch "main"
This commit is contained in:
44
packages/email/providers/branding.tsx
Normal file
44
packages/email/providers/branding.tsx
Normal file
@ -0,0 +1,44 @@
|
||||
'use client';
|
||||
|
||||
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;
|
||||
Reference in New Issue
Block a user