mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
'use client';
|
|
|
|
import { useEffect, useState } from 'react';
|
|
import { useRouter } from 'next/navigation';
|
|
import Sidebar from '@/components/layout/Sidebar';
|
|
import Header from '@/components/layout/Header';
|
|
import { useAuthStore } from '@/lib/auth-store';
|
|
|
|
export default function HealthLayout({ children }: { children: React.ReactNode }) {
|
|
const router = useRouter();
|
|
const { isAuthenticated } = useAuthStore();
|
|
const [isLoading, setIsLoading] = useState(true);
|
|
|
|
useEffect(() => {
|
|
const timer = setTimeout(() => setIsLoading(false), 100);
|
|
return () => clearTimeout(timer);
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
if (!isLoading && !isAuthenticated) router.push('/login');
|
|
}, [isAuthenticated, router, isLoading]);
|
|
|
|
if (isLoading) {
|
|
return (
|
|
<div className="flex h-screen items-center justify-center bg-gray-50 dark:bg-slate-950">
|
|
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-edr-green-600" />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (!isAuthenticated) return null;
|
|
|
|
return (
|
|
<div className="flex h-screen overflow-hidden bg-gray-50 dark:bg-slate-950">
|
|
<Sidebar />
|
|
<div className="flex flex-1 flex-col overflow-hidden">
|
|
<Header />
|
|
<main className="flex-1 overflow-y-auto bg-gray-50 dark:bg-slate-950 p-6">
|
|
{children}
|
|
</main>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|