34 lines
872 B
TypeScript
34 lines
872 B
TypeScript
import React from 'react';
|
|
import { Outlet, Navigate } from 'react-router-dom';
|
|
import { useAuth } from '../../context/AuthContext';
|
|
import { Navbar } from './Navbar';
|
|
import { Sidebar } from './Sidebar';
|
|
|
|
export const AppLayout: React.FC = () => {
|
|
const { isAuthenticated, isLoading } = useAuth();
|
|
|
|
if (isLoading) {
|
|
return (
|
|
<div className="min-h-screen flex items-center justify-center bg-slate-50">
|
|
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"></div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (!isAuthenticated) {
|
|
return <Navigate to="/login" replace />;
|
|
}
|
|
|
|
return (
|
|
<div className="min-h-screen bg-slate-50 flex flex-col">
|
|
<Navbar />
|
|
<div className="flex flex-1">
|
|
<Sidebar />
|
|
<main className="flex-1 p-6 max-w-7xl">
|
|
<Outlet />
|
|
</main>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|