import Head from 'next/head' import { FC, ReactNode } from 'react' import { observer } from 'mobx-react-lite' import { isUndefined } from 'lodash' import { useRouter } from 'next/router' import { Project } from 'types' import { useStore } from 'hooks' import Connecting from 'components/ui/Loading' import NavigationBar from './NavigationBar/NavigationBar' import ProductMenuBar from './ProductMenuBar' import LayoutHeader from './LayoutHeader' import TestConnection from './TestConnection' interface Props { title?: string isLoading?: boolean product?: string productMenu?: ReactNode children: ReactNode hideHeader?: boolean hideIconBar?: boolean } const BaseLayout: FC = ({ title, isLoading = false, product = '', productMenu, children, hideHeader = false, hideIconBar = false, }) => { const { ui } = useStore() const project: Project | undefined = ui.selectedProject const router = useRouter() const requiresDbConnection: boolean = router.pathname !== '/project/[ref]/settings/general' // useEffect(() => { // if (isUndefined(project)) router.push('/404') // }, []) const renderContent = () => { if (!isUndefined(project)) { return requiresDbConnection ? ( {isLoading ? ( ) : (
{children}
)}
) : ( <>{children} ) } else { return <>{children} } } return ( <> {title ? `${title} | Supabase` : 'Supabase'}
{/* Left-most navigation side bar to access products */} {!hideIconBar && } {/* Product menu bar */} {productMenu && !isLoading && ( {productMenu} )}
{!hideHeader && } {renderContent()}
) } export default observer(BaseLayout)