File size: 936 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
import { createContext, useContext } from 'react';
export type AppConfig = {
basePath: string;
mainRoute: string;
Logo: React.FC | null;
LoadingLogo?: React.FC;
supports: {
overview: boolean;
sites: boolean;
domains: boolean;
emails: boolean;
reader: boolean;
help: boolean;
notifications: boolean;
me: boolean;
};
};
const AppContext = createContext< AppConfig >( {
basePath: '',
mainRoute: '',
Logo: null,
LoadingLogo: undefined,
supports: {
overview: false,
sites: false,
domains: false,
emails: false,
reader: false,
help: false,
notifications: false,
me: false,
},
} );
interface AppProviderProps {
children: React.ReactNode;
config: AppConfig;
}
export function AppProvider( { children, config }: AppProviderProps ) {
return <AppContext.Provider value={ { ...config } }>{ children }</AppContext.Provider>;
}
export function useAppContext() {
return useContext( AppContext );
}
|