Repository navigation
Expand file tree
/
Copy pathLayout.js
More file actions
59 lines (51 loc) · 1.87 KB
/
Copy pathLayout.js
File metadata and controls
59 lines (51 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import React, { useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
import Sidebar from '@/components/layout/Sidebar';
import CurriculumSelector from '@/components/dashboard/CurriculumSelector';
import { base44 } from '@/api/base44Client';
import { StudyProvider, useStudy } from '@/components/context/StudyContext';
// Inner layout component to consume context
const LayoutContent = ({ children }) => {
const { profile, loading, setProfile } = useStudy();
const [showSelector, setShowSelector] = useState(false);
const [initChecked, setInitChecked] = useState(false);
useEffect(() => {
if (!loading) {
if (!profile) {
setShowSelector(true);
} else {
setShowSelector(false);
}
setInitChecked(true);
}
}, [loading, profile]);
const handleCurriculumSelected = (newProfile) => {
setProfile(newProfile);
setShowSelector(false);
};
if (!initChecked && loading) return null; // Or a loading spinner
return (
<div className="flex h-screen bg-[#121212] text-white overflow-hidden font-sans">
<Sidebar profile={profile} />
<main className="flex-1 overflow-y-auto overflow-x-hidden relative">
<div className="absolute inset-0 bg-gradient-to-br from-[#121212] via-[#121212] to-[#1a1a2e] -z-10 pointer-events-none" />
<div className="p-6 md:p-8 max-w-7xl mx-auto min-h-full">
{children}
</div>
</main>
{showSelector && (
<CurriculumSelector onComplete={handleCurriculumSelected} />
)}
</div>
);
};
export default function Layout({ children }) {
return (
<StudyProvider>
<style>{`
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');
`}</style>
<LayoutContent>{children}</LayoutContent>
</StudyProvider>
);
}