import { PropsWithChildren } from 'react' import { useParams } from 'common' import { AppBannerWrapper } from 'components/interfaces/App' import { AppBannerContextProvider } from 'components/interfaces/App/AppBannerWrapperContext' import { useIsNewLayoutEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext' import { Sidebar } from 'components/interfaces/Sidebar' import { useShowLayoutHeader } from 'hooks/misc/useShowLayoutHeader' import { useRouter } from 'next/router' import { SidebarProvider } from 'ui' import { LayoutHeader } from './ProjectLayout/LayoutHeader' import MobileNavigationBar from './ProjectLayout/NavigationBar/MobileNavigationBar' import { ProjectContextProvider } from './ProjectLayout/ProjectContext' export interface DefaultLayoutProps { headerTitle?: string } /** * Base layout for all project pages in the dashboard, rendered as the first child on all page files within a project. * * A second layout as the child to this is required, and the layout depends on which section of the dashboard the page is on. (e.g Auth - AuthLayout) * * The base layout handles rendering the following UI components: * - App banner (e.g for notices or incidents) * - Mobile navigation bar * - First level side navigation bar (e.g For navigating to Table Editor, SQL Editor, Database page, etc) */ const DefaultLayout = ({ children, headerTitle }: PropsWithChildren) => { const newLayoutPreview = useIsNewLayoutEnabled() const showLayoutHeader = useShowLayoutHeader() const { ref } = useParams() const router = useRouter() const showProductMenu = !!ref && router.pathname !== '/project/[ref]' return (
{/* Top Banner */}
{newLayoutPreview || showLayoutHeader ? ( ) : null}
{/* Main Content Area */}
{/* Sidebar */} {/* Main Content */}
{children}
) } export default DefaultLayout