Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

933 B
Raw Blame
'use client'

import { useForceDeepDark } from 'lib/theme.utils'
import { usePathname } from 'next/navigation'
import { PRODUCT_NAMES } from 'shared-data/products'

import ProductsNav from '../../components/Products/ProductsNav'
import DefaultLayout from '@/components/Layouts/Default'

const SEGMENT_TO_PRODUCT: Record<string, PRODUCT_NAMES> = {
  database: PRODUCT_NAMES.DATABASE,
  auth: PRODUCT_NAMES.AUTHENTICATION,
  storage: PRODUCT_NAMES.STORAGE,
  'edge-functions': PRODUCT_NAMES.FUNCTIONS,
  compute: PRODUCT_NAMES.COMPUTE,
  realtime: PRODUCT_NAMES.REALTIME,
}

export default function ProductsLayout({ children }: { children: React.ReactNode }) {
  useForceDeepDark()

  const pathname = usePathname()
  const segment = pathname?.split('/')[1] ?? ''
  const activePage = SEGMENT_TO_PRODUCT[segment]

  return (
    <DefaultLayout>
      <ProductsNav activePage={activePage} />
      {children}
    </DefaultLayout>
  )
}