-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
84 lines (73 loc) · 3.56 KB
/
App.tsx
File metadata and controls
84 lines (73 loc) · 3.56 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
import React, { useEffect } from 'react';
import { HashRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
import { useDispatch } from 'react-redux';
import { AppDispatch } from './store/store';
import { setSession } from './store/slices/authSlice';
import { AuthService } from './services/AuthService';
import { Gateway } from './pages/Gateway';
import { Dashboard } from './pages/Dashboard';
import { Templates } from './pages/Templates';
import { AgentRuns } from './pages/AgentRuns';
import { Agents } from './pages/Agents';
import { AgentProfileDetail } from './pages/AgentProfile';
import { Console } from './pages/Console';
import { Interview } from './pages/Interview';
import { CertificateList } from './pages/Certificate';
import { CertificateDetail } from './pages/CertificateDetail';
import { LoginPage } from './pages/LoginPage';
import { SignUpPage } from './pages/SignUpPage';
import { ResetPasswordPage } from './pages/ResetPasswordPage';
import PublicAgentProfile from './pages/PublicAgentProfile';
import PublicCertificate from './pages/PublicCertificate';
import { PublicTemplates } from './pages/PublicTemplates';
import { PublicTemplateDetails } from './pages/PublicTemplateDetails';
import { ProtectedRoute } from './components/ProtectedRoute';
const AppContent: React.FC = () => {
const dispatch = useDispatch<AppDispatch>();
useEffect(() => {
// Initialize session check
AuthService.getSession().then(({ session }) => {
dispatch(setSession({ session, user: session?.user ?? null }));
});
// Listen for changes
const { data: { subscription } } = AuthService.onAuthStateChange((_event, session) => {
dispatch(setSession({ session, user: session?.user ?? null }));
});
return () => subscription.unsubscribe();
}, [dispatch]);
return (
<Routes>
{/* Public Routes */}
<Route path="/" element={<Gateway />} />
<Route path="/login" element={<LoginPage />} />
<Route path="/signup" element={<SignUpPage />} />
<Route path="/reset-password" element={<ResetPasswordPage />} />
<Route path="/public/agents/:id" element={<PublicAgentProfile />} />
<Route path="/public/certificates/:id" element={<PublicCertificate />} />
<Route path="/explore" element={<PublicTemplates />} />
<Route path="/explore/:id" element={<PublicTemplateDetails />} />
<Route path="/interview" element={<Interview />} />
{/* Protected Routes */}
<Route path="/dashboard" element={<ProtectedRoute><Dashboard /></ProtectedRoute>} />
<Route path="/templates/*" element={<ProtectedRoute><Templates /></ProtectedRoute>} />
<Route path="/agents" element={<ProtectedRoute><Agents /></ProtectedRoute>} />
<Route path="/agents/:id" element={<ProtectedRoute><AgentProfileDetail /></ProtectedRoute>} />
<Route path="/agents/:id" element={<ProtectedRoute><AgentProfileDetail /></ProtectedRoute>} />
<Route path="/interviews" element={<ProtectedRoute><AgentRuns /></ProtectedRoute>} />
<Route path="/session" element={<ProtectedRoute><Console /></ProtectedRoute>} />
<Route path="/certificates" element={<ProtectedRoute><CertificateList /></ProtectedRoute>} />
<Route path="/certificate/:id" element={<ProtectedRoute><CertificateDetail /></ProtectedRoute>} />
<Route path="/session" element={<ProtectedRoute><Console /></ProtectedRoute>} />
{/* Fallback */}
<Route path="*" element={<Navigate to="/" replace />} />
</Routes>
);
};
const App: React.FC = () => {
return (
<Router>
<AppContent />
</Router>
);
};
export default App;