feat: Next.js 14 web admin scaffold — auth, sidebar, dashboard, placeholders
This commit is contained in:
32
app/(app)/layout.tsx
Normal file
32
app/(app)/layout.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useAuthStore } from '@/lib/auth-store';
|
||||
import Sidebar from '@/components/layout/sidebar';
|
||||
import Topbar from '@/components/layout/topbar';
|
||||
|
||||
export default function AppLayout({ children }: { children: React.ReactNode }) {
|
||||
const router = useRouter();
|
||||
const accessToken = useAuthStore((s) => s.accessToken);
|
||||
|
||||
useEffect(() => {
|
||||
if (!accessToken) {
|
||||
router.replace('/login');
|
||||
}
|
||||
}, [accessToken, router]);
|
||||
|
||||
if (!accessToken) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex min-h-screen" style={{ backgroundColor: '#F8FAFC' }}>
|
||||
<Sidebar />
|
||||
<div className="flex-1 flex flex-col overflow-hidden">
|
||||
<Topbar />
|
||||
<main className="flex-1 overflow-y-auto p-6">{children}</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user