2025-04-07 15:42:09 +08:00
|
|
|
import {ReactNode} from 'react'
|
|
|
|
|
import {merge} from '@/lib/utils'
|
2025-04-08 11:21:58 +08:00
|
|
|
import {redirect} from 'next/navigation'
|
2025-04-23 19:00:53 +08:00
|
|
|
import {getProfile} from '@/actions/auth/auth'
|
2025-04-25 16:24:04 +08:00
|
|
|
import Header from './_client/header'
|
|
|
|
|
import Navbar from '@/app/admin/_client/navbar'
|
2025-04-07 15:42:09 +08:00
|
|
|
|
|
|
|
|
export type DashboardLayoutProps = {
|
|
|
|
|
children: ReactNode
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default async function DashboardLayout(props: DashboardLayoutProps) {
|
2025-04-08 11:21:58 +08:00
|
|
|
|
2025-04-25 16:24:04 +08:00
|
|
|
// ======================
|
|
|
|
|
// profile
|
|
|
|
|
// ======================
|
|
|
|
|
|
2025-04-23 19:00:53 +08:00
|
|
|
const user = await getProfile()
|
|
|
|
|
if (!user) {
|
|
|
|
|
return redirect(`/login?redirect=${encodeURIComponent('/admin')}`)
|
2025-04-08 11:21:58 +08:00
|
|
|
}
|
|
|
|
|
|
2025-04-25 16:24:04 +08:00
|
|
|
// ======================
|
|
|
|
|
// render
|
|
|
|
|
// ======================
|
2025-04-07 15:42:09 +08:00
|
|
|
|
2025-04-25 16:24:04 +08:00
|
|
|
return (
|
|
|
|
|
<div className={merge(
|
|
|
|
|
`h-screen bg-card overflow-hidden min-w-7xl overflow-y-hidden`,
|
|
|
|
|
`flex items-stretch`,
|
|
|
|
|
)}>
|
2025-04-07 15:42:09 +08:00
|
|
|
|
2025-04-25 16:24:04 +08:00
|
|
|
<Navbar/>
|
2025-04-07 15:42:09 +08:00
|
|
|
|
2025-04-25 16:24:04 +08:00
|
|
|
<div className={`flex-auto flex flex-col items-stretch`}>
|
|
|
|
|
<Header/>
|
2025-04-07 15:42:09 +08:00
|
|
|
{props.children}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|