import Link from 'next/link'
import { useRouter } from 'next/router'
import React, { useEffect } from 'react'
import { observer } from 'mobx-react-lite'
import { IconCode, Loading } from '@supabase/ui'
import { useStore, withAuth } from 'hooks'
import FunctionsNav from './FunctionsNav'
import BaseLayout from 'components/layouts'
const FunctionsLayout = ({ children }: { children?: React.ReactNode }) => {
const { functions, ui } = useStore()
const router = useRouter()
const { id, ref } = router.query
useEffect(() => {
if (ui.selectedProjectRef) {
functions.load()
}
}, [ui.selectedProjectRef])
if (!functions.isLoaded) {
return (
{''}
)
}
const item = id ? functions.byId(id) : null
const name = item?.name || ''
const hasFunctions = functions.list().length > 0
const centered = !hasFunctions
return (
{centered ? (
<>
>
) : (
{name && (
<>
{name}
>
)}
{item &&
}
{children}
)}
)
}
export default withAuth(observer(FunctionsLayout))