Files
web/src/app/admin/layout.tsx

42 lines
944 B
TypeScript
Raw Normal View History

import {ReactNode} from 'react'
import {merge} from '@/lib/utils'
import {redirect} from 'next/navigation'
import {getProfile} from '@/actions/auth/auth'
import Header from './_client/header'
import Navbar from '@/app/admin/_client/navbar'
export type DashboardLayoutProps = {
children: ReactNode
}
export default async function DashboardLayout(props: DashboardLayoutProps) {
// ======================
// profile
// ======================
const user = await getProfile()
if (!user) {
return redirect(`/login?redirect=${encodeURIComponent('/admin')}`)
}
// ======================
// render
// ======================
return (
<div className={merge(
`h-screen bg-card overflow-hidden min-w-7xl overflow-y-hidden`,
`flex items-stretch`,
)}>
<Navbar/>
<div className={`flex-auto flex flex-col items-stretch`}>
<Header/>
{props.children}
</div>
</div>
)
}