feat: revue de code, doc CODE_REVIEW, forfaits 2026, traduction LLM, providers avec modèle
Made-with: Cursor
This commit is contained in:
43
frontend/src/app/dashboard/DashboardLayoutClient.tsx
Normal file
43
frontend/src/app/dashboard/DashboardLayoutClient.tsx
Normal file
@@ -0,0 +1,43 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { DashboardSidebar } from './DashboardSidebar';
|
||||
import { DashboardHeader } from './DashboardHeader';
|
||||
|
||||
export function DashboardLayoutClient({ children }: { children: React.ReactNode }) {
|
||||
const router = useRouter();
|
||||
const [mounted, setMounted] = useState(false);
|
||||
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true);
|
||||
const token = localStorage.getItem('token');
|
||||
if (!token) {
|
||||
router.push('/auth/login?redirect=/dashboard');
|
||||
} else {
|
||||
setIsAuthenticated(true);
|
||||
}
|
||||
}, [router]);
|
||||
|
||||
if (!mounted || !isAuthenticated) {
|
||||
return (
|
||||
<div className="flex h-screen items-center justify-center bg-background">
|
||||
<div className="text-center space-y-4">
|
||||
<div className="animate-spin rounded-full h-8 w-8 border-4 border-muted border-t-foreground mx-auto"></div>
|
||||
<p className="text-sm text-muted-foreground">Loading...</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex h-screen bg-background">
|
||||
<DashboardSidebar />
|
||||
<div className="flex flex-1 flex-col overflow-hidden">
|
||||
<DashboardHeader />
|
||||
<main className="flex-1 overflow-y-auto">{children}</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user