Repository navigation
Expand file tree
/
Copy pathApp.tsx
More file actions
84 lines (76 loc) · 2.72 KB
/
Copy pathApp.tsx
File metadata and controls
84 lines (76 loc) · 2.72 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* @license
* SPDX-License-Identifier: Apache-2.0
*/
import { useEffect, useState } from 'react';
import { BrowserRouter, Route, Routes, useLocation, useNavigate } from 'react-router-dom';
import { AuthProvider } from './context/AuthContext';
import { AppShell } from './components/layout/AppShell';
import { LandingPage } from './components/LandingPage';
import { ScholarshipExplorer } from './components/ScholarshipExplorer';
import { ApplicationTracker } from './components/ApplicationTracker';
import { SourceTransparency } from './components/SourceTransparency';
import { ScholarshipDetailPage } from './pages/ScholarshipDetailPage';
import { AuthPage } from './pages/AuthPage';
import { ProfileBuilder } from './components/ProfileBuilder';
import { NotFoundPage } from './pages/NotFoundPage';
function ScrollToTop() {
const { pathname } = useLocation();
useEffect(() => {
window.scrollTo({ top: 0 });
}, [pathname]);
return null;
}
function MainApp() {
const [showProfileBuilder, setShowProfileBuilder] = useState(false);
const navigate = useNavigate();
useEffect(() => {
const handler = () => setShowProfileBuilder(true);
window.addEventListener('open-profile-builder', handler);
return () => window.removeEventListener('open-profile-builder', handler);
}, []);
const handleNavigate = (tab: string) => {
navigate(tab === 'landing' ? '/' : `/${tab}`);
};
return (
<AppShell onOpenProfileBuilder={() => setShowProfileBuilder(true)}>
<ScrollToTop />
<Routes>
<Route
path="/"
element={
<LandingPage
onNavigate={handleNavigate}
onOpenProfileBuilder={() => setShowProfileBuilder(true)}
/>
}
/>
<Route path="/explore" element={<ScholarshipExplorer onOpenProfileBuilder={() => setShowProfileBuilder(true)} />} />
<Route path="/tracker" element={<ApplicationTracker onExplore={() => navigate('/explore')} />} />
<Route path="/sources" element={<SourceTransparency />} />
<Route path="/scholarship/:id" element={<ScholarshipDetailPage />} />
<Route path="/login" element={<AuthPage mode="login" />} />
<Route path="/signup" element={<AuthPage mode="signup" />} />
<Route path="*" element={<NotFoundPage />} />
</Routes>
{showProfileBuilder ? (
<ProfileBuilder
onClose={() => setShowProfileBuilder(false)}
onFinished={() => {
setShowProfileBuilder(false);
navigate('/explore');
}}
/>
) : null}
</AppShell>
);
}
export default function App() {
return (
<AuthProvider>
<BrowserRouter>
<MainApp />
</BrowserRouter>
</AuthProvider>
);
}