import { Navigate, Outlet, useParams } from 'react-router-dom';
import { ProjectSidebar } from '@/components/project/sidebar';
import { ProjectProvider } from '@/contexts';

export function ProjectLayout() {
    const { project_name } = useParams<{ project_name: string }>();

    if (!project_name) {
        return <Navigate to="/404" replace />;
    }

    return (
        <ProjectProvider projectName={project_name}>
            <div className="flex h-screen w-full bg-background">
                <ProjectSidebar />
                <main className="flex-1 overflow-y-auto">
                    <Outlet />
                </main>
            </div>
        </ProjectProvider>
    );
}
