33 lines
861 B
TypeScript
33 lines
861 B
TypeScript
'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>
|
|
);
|
|
}
|