Seth0330 commited on
Commit
c6e39c8
·
verified ·
1 Parent(s): 2f6e72f

Update frontend/src/App.jsx

Browse files
Files changed (1) hide show
  1. frontend/src/App.jsx +11 -2
frontend/src/App.jsx CHANGED
@@ -38,6 +38,15 @@ function RequireCoach({ children }) {
38
  return children;
39
  }
40
 
 
 
 
 
 
 
 
 
 
41
  export default function App() {
42
  return (
43
  <Routes>
@@ -112,9 +121,9 @@ export default function App() {
112
  <Route
113
  path="/admin/students/:id"
114
  element={
115
- <RequireAdmin>
116
  <StudentProfile />
117
- </RequireAdmin>
118
  }
119
  />
120
 
 
38
  return children;
39
  }
40
 
41
+ function RequireAdminOrCoach({ children }) {
42
+ const storedAdmin = sessionStorage.getItem("admin");
43
+ const storedCoach = localStorage.getItem("karateCoach");
44
+ if (!storedAdmin && !storedCoach) {
45
+ return <Navigate to="/login" replace />;
46
+ }
47
+ return children;
48
+ }
49
+
50
  export default function App() {
51
  return (
52
  <Routes>
 
121
  <Route
122
  path="/admin/students/:id"
123
  element={
124
+ <RequireAdminOrCoach>
125
  <StudentProfile />
126
+ </RequireAdminOrCoach>
127
  }
128
  />
129