import React, { createContext, useContext } from 'react'; import { ActiveNavElement, CurrentOrganizationInterface, CurrentProjectInterface, MongoNavInterface, Product, } from './types'; // TODO: Add additional props to context /* e.g. { urls: URLS; hosts: Required; activePlatform: Platform; activeNav?: ActiveNavElement; isAdmin?: boolean; mode?: ProductionMode; environment?: Environment; } */ export interface MongoNavContextProps extends Pick< MongoNavInterface, 'useAppServicesBranding' | 'showUnifiedAccessManagementNav' > { isLoading: boolean; activeNav?: ActiveNavElement; activeProduct?: Product; currentOrg?: CurrentOrganizationInterface | null; currentProject?: CurrentProjectInterface; } export const defaultMongoNavContext = { // TODO: Rewrite tests so default isLoading: true, doesn't break tests isLoading: false, useAppServicesBranding: true, showUnifiedAccessManagementNav: false, } as const; const MongoNavContext = createContext( defaultMongoNavContext, ); export const MongoNavProvider = ({ children, context, }: { children: React.ReactNode; context: MongoNavContextProps; }) => { return ( {children} ); }; export const useMongoNavContext = () => { return useContext(MongoNavContext); };