mirror of
https://github.com/supabase/supabase.git
synced 2026-05-09 18:30:12 -04:00
4a0bb36ca8
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { useRouter } from 'next/router'
|
|
import type { PropsWithChildren } from 'react'
|
|
|
|
import { ProjectLayout } from '../ProjectLayout'
|
|
import { useGenerateSettingsMenu } from './SettingsMenu.utils'
|
|
import { ProductMenu } from '@/components/ui/ProductMenu'
|
|
import { withAuth } from '@/hooks/misc/withAuth'
|
|
|
|
/**
|
|
* Menu-only component for the settings section. Used by the desktop sidebar and by the
|
|
* mobile sheet submenu. Must not wrap ProjectLayout so that opening the settings submenu
|
|
* in the mobile sheet does not overwrite registerOpenMenu and break the menu button.
|
|
*/
|
|
export const SettingsProductMenu = () => {
|
|
const router = useRouter()
|
|
|
|
const page = router.pathname.includes('billing')
|
|
? router.pathname.split('/')[5]
|
|
: router.pathname.split('/')[4]
|
|
|
|
const menu = useGenerateSettingsMenu()
|
|
|
|
return <ProductMenu page={page} menu={menu} />
|
|
}
|
|
|
|
interface SettingsLayoutProps {
|
|
title: string
|
|
}
|
|
|
|
export const SettingsLayout = ({ title, children }: PropsWithChildren<SettingsLayoutProps>) => {
|
|
return (
|
|
<ProjectLayout
|
|
isBlocking={false}
|
|
product="Settings"
|
|
browserTitle={{ section: title }}
|
|
productMenu={<SettingsProductMenu />}
|
|
>
|
|
{children}
|
|
</ProjectLayout>
|
|
)
|
|
}
|
|
|
|
export default withAuth(SettingsLayout)
|