Files
supabase/apps/studio/components/layouts/AuthLayout/AuthLayout.tsx
Kevin Grüneberg 13cfc0abb5 fix: barrel imports (#21728)
Avoid importing all components via barrel files that lead to bloated bundles/chunks
2024-03-04 18:39:53 +08:00

45 lines
1.3 KiB
TypeScript

import { useParams } from 'common'
import { useRouter } from 'next/router'
import { PropsWithChildren } from 'react'
import { useIsColumnLevelPrivilegesEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import { ProductMenu } from 'components/ui/ProductMenu'
import { useAuthConfigPrefetch } from 'data/auth/auth-config-query'
import { withAuth } from 'hooks'
import { ProjectLayout } from '../'
import { generateAuthMenu } from './AuthLayout.utils'
export interface AuthLayoutProps {
title?: string
}
const AuthLayout = ({ title, children }: PropsWithChildren<AuthLayoutProps>) => {
const { ref: projectRef = 'default' } = useParams()
const columnLevelPrivileges = useIsColumnLevelPrivilegesEnabled()
useAuthConfigPrefetch({ projectRef })
const router = useRouter()
const page = router.pathname.split('/')[4]
return (
<ProjectLayout
title={title || 'Authentication'}
product="Authentication"
productMenu={
<ProductMenu
page={page}
menu={generateAuthMenu(projectRef ?? 'default', { columnLevelPrivileges })}
/>
}
isBlocking={false}
>
<main style={{ maxHeight: '100vh' }} className="flex-1 overflow-y-auto">
{children}
</main>
</ProjectLayout>
)
}
export default withAuth(AuthLayout)