import Head from 'next/head' import { useRouter } from 'next/router' import { PropsWithChildren, useEffect } from 'react' import { LOCAL_STORAGE_KEYS } from 'common' import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage' import { withAuth } from 'hooks/misc/withAuth' import { IS_PLATFORM } from 'lib/constants' import { useAppStateSnapshot } from 'state/app-state' import { cn } from 'ui' import { WithSidebar } from './WithSidebar' export interface AccountLayoutProps { title: string } const AccountLayout = ({ children, title }: PropsWithChildren) => { const router = useRouter() const appSnap = useAppStateSnapshot() const [lastVisitedOrganization] = useLocalStorageQuery( LOCAL_STORAGE_KEYS.LAST_VISITED_ORGANIZATION, '' ) const backToDashboardURL = appSnap.lastRouteBeforeVisitingAccountPage.length > 0 ? appSnap.lastRouteBeforeVisitingAccountPage : !!lastVisitedOrganization ? `/org/${lastVisitedOrganization}` : '/organizations' const currentPath = router.pathname useEffect(() => { if (!IS_PLATFORM) { router.push('/project/default') } }, [router]) return ( <> {title ? `${title} | Supabase` : 'Supabase'}
{children}
) } export default withAuth(AccountLayout)