1- // Put this file in: src/App.jsx (replaces your file)
2- // Changes compared to your App.jsx:
3- // 1) /interview/:id and /interview/:id/call now open the new in-app call page (InterviewCall),
4- // for BOTH the user and the admin (it used to be user only, so the admin could never join)
5- // 2) new admin routes: /admin/live (live interviews with Join button) and /admin/applications
1+
62import { Routes , Route , Navigate } from "react-router-dom" ;
73
84// Authentication & Protected Routes
9- import ProtectedRoute from "./ProtectedRoute.jsx" ;
5+ // import ProtectedRoute from "./ProtectedRoute.jsx";
6+
7+ import ProtectedRoute from "./Protectedroute.jsx" ;
108
119// Public Pages
1210import Home from "./Home.jsx" ;
1311import Login from "./Login.jsx" ;
1412import SignUp from "./SignUp.jsx" ;
1513import JobListing from "./JobListing.jsx" ;
16- // import JobSearch from "./JobSearch.jsx";
1714import Companies from "./Companies.jsx" ;
1815import CompanyDetails from "./CompanyDetails.jsx" ;
1916import HelpFAQ from "./HelpFAQ.jsx" ;
2017import AboutUs from "./AboutUs.jsx" ;
2118import ContactUs from "./ContactUs.jsx" ;
2219
23-
2420// User Pages
2521import ApplyJob from "./ApplyJob.jsx" ;
2622import Dashboard from "./Dashboard.jsx" ;
@@ -29,9 +25,8 @@ import Notifications from "./Notifications.jsx";
2925import Profile from "./Profile.jsx" ;
3026import Settings from "./Settings.jsx" ;
3127import MyInterviews from "./MyInterviews.jsx" ;
32- // import InterviewRoom from "./InterviewRoom.jsx"; // replaced by InterviewCall (you can delete InterviewRoom.jsx later)
3328
34- // Interview call page (used by the user AND the admin)
29+ // Interview Call
3530import InterviewCall from "./InterviewCall.jsx" ;
3631
3732// Admin Pages
@@ -44,7 +39,7 @@ export default function App() {
4439 return (
4540 < Routes >
4641
47- { /* ================= PUBLIC ROUTES ================= */ }
42+ { /* PUBLIC ROUTES */ }
4843
4944 < Route path = "/" element = { < Home /> } />
5045
@@ -54,8 +49,6 @@ export default function App() {
5449
5550 < Route path = "/jobs" element = { < JobListing /> } />
5651
57- { /* <Route path="/search" element={<JobSearch />} /> */ }
58-
5952 < Route path = "/companies" element = { < Companies /> } />
6053
6154 < Route
@@ -70,7 +63,7 @@ export default function App() {
7063 < Route path = "/contact" element = { < ContactUs /> } />
7164
7265
73- { /* ================= USER PROTECTED ROUTES ================= */ }
66+ { /* USER PROTECTED ROUTES */ }
7467
7568 < Route
7669 path = "/apply/:id"
@@ -136,16 +129,28 @@ export default function App() {
136129 />
137130
138131
139- { /* ================= INTERVIEW CALL (user and admin) =================
140- No role here on purpose: both the candidate and the recruiter (admin) must be able to open it.
141- The backend (CallController) checks that the person really belongs to this interview. */ }
132+ { /* INTERVIEW CALL - USER AND ADMIN */ }
142133
143- < Route path = "/interview/:id" element = { < InterviewCall /> } />
134+ < Route
135+ path = "/interview/:id"
136+ element = {
137+ < ProtectedRoute >
138+ < InterviewCall />
139+ </ ProtectedRoute >
140+ }
141+ />
144142
145- < Route path = "/interview/:id/call" element = { < InterviewCall /> } />
143+ < Route
144+ path = "/interview/:id/call"
145+ element = {
146+ < ProtectedRoute >
147+ < InterviewCall />
148+ </ ProtectedRoute >
149+ }
150+ />
146151
147152
148- { /* ================= ADMIN PROTECTED ROUTES ================= */ }
153+ { /* ADMIN PROTECTED ROUTES */ }
149154
150155 < Route
151156 path = "/admin"
@@ -184,7 +189,7 @@ export default function App() {
184189 />
185190
186191
187- { /* ================= UNKNOWN ROUTES ================= */ }
192+ { /* UNKNOWN ROUTES */ }
188193
189194 < Route
190195 path = "*"
@@ -194,222 +199,3 @@ export default function App() {
194199 </ Routes >
195200 ) ;
196201}
197-
198-
199-
200-
201-
202- // // Put this file in: src/App.jsx (replaces your file)
203- // // Changes compared to your App.jsx:
204- // // 1) ProtectedRoute now comes from RequireRole.jsx. It sends the person to /login when there is no token
205- // // or the token has expired (before, an old login still opened the admin page with an empty list),
206- // // and sends the wrong role (a USER on an admin page) to the home page.
207- // // 2) /interview/:id and /interview/:id/call open the in-app call page (InterviewCall) for BOTH the
208- // // user and the admin. They need a login, but no fixed role.
209- // // 3) admin routes: /admin/live and /admin/applications
210- // // Needs these files in src/: RequireRole.jsx and the newer api.js (from the careerhub-fix4 folder)
211- // import { Routes, Route, Navigate } from "react-router-dom";
212-
213- // // Authentication & Protected Routes
214- // import ProtectedRoute from "./RequireRole.jsx"; // was ./ProtectedRoute.jsx
215-
216- // // Public Pages
217- // import Home from "./Home.jsx";
218- // import Login from "./Login.jsx";
219- // import SignUp from "./SignUp.jsx";
220- // import JobListing from "./JobListing.jsx";
221- // // import JobSearch from "./JobSearch.jsx";
222- // import Companies from "./Companies.jsx";
223- // import CompanyDetails from "./CompanyDetails.jsx";
224- // import HelpFAQ from "./HelpFAQ.jsx";
225- // import AboutUs from "./AboutUs.jsx";
226- // import ContactUs from "./ContactUs.jsx";
227-
228- // // User Pages
229- // import ApplyJob from "./ApplyJob.jsx";
230- // import Dashboard from "./Dashboard.jsx";
231- // import Messages from "./Messages.jsx";
232- // import Notifications from "./Notifications.jsx";
233- // import Profile from "./Profile.jsx";
234- // import Settings from "./Settings.jsx";
235- // import MyInterviews from "./MyInterviews.jsx";
236- // // import InterviewRoom from "./InterviewRoom.jsx"; // replaced by InterviewCall (you can delete InterviewRoom.jsx later)
237-
238- // // Interview call page (used by the user AND the admin)
239- // import InterviewCall from "./InterviewCall.jsx";
240-
241- // // Admin Pages
242- // import AdminDashboard from "./AdminDashboard.jsx";
243- // import AdminJobs from "./admin/AdminJobs.jsx";
244- // import AdminApplications from "./admin/AdminApplications.jsx";
245- // import LiveInterviews from "./admin/LiveInterviews.jsx";
246-
247- // export default function App() {
248- // return (
249- // <Routes>
250-
251- // {/* ================= PUBLIC ROUTES ================= */}
252-
253- // <Route path="/" element={<Home />} />
254-
255- // <Route path="/login" element={<Login />} />
256-
257- // <Route path="/signup" element={<SignUp />} />
258-
259- // <Route path="/jobs" element={<JobListing />} />
260-
261- // {/* <Route path="/search" element={<JobSearch />} /> */ }
262-
263- // <Route path="/companies" element={<Companies />} />
264-
265- // <Route
266- // path="/companies/:id"
267- // element={<CompanyDetails />}
268- // />
269-
270- // <Route path="/help" element={<HelpFAQ />} />
271-
272- // <Route path="/about" element={<AboutUs />} />
273-
274- // <Route path="/contact" element={<ContactUs />} />
275-
276-
277- // {/* ================= USER PROTECTED ROUTES ================= */}
278-
279- // <Route
280- // path="/apply/:id"
281- // element={
282- // <ProtectedRoute role="USER">
283- // <ApplyJob />
284- // </ProtectedRoute>
285- // }
286- // />
287-
288- // <Route
289- // path="/dashboard"
290- // element={
291- // <ProtectedRoute role="USER">
292- // <Dashboard />
293- // </ProtectedRoute>
294- // }
295- // />
296-
297- // <Route
298- // path="/messages"
299- // element={
300- // <ProtectedRoute role="USER">
301- // <Messages />
302- // </ProtectedRoute>
303- // }
304- // />
305-
306- // <Route
307- // path="/notifications"
308- // element={
309- // <ProtectedRoute role="USER">
310- // <Notifications />
311- // </ProtectedRoute>
312- // }
313- // />
314-
315- // <Route
316- // path="/profile"
317- // element={
318- // <ProtectedRoute role="USER">
319- // <Profile />
320- // </ProtectedRoute>
321- // }
322- // />
323-
324- // <Route
325- // path="/settings"
326- // element={
327- // <ProtectedRoute role="USER">
328- // <Settings />
329- // </ProtectedRoute>
330- // }
331- // />
332-
333- // <Route
334- // path="/my-interviews"
335- // element={
336- // <ProtectedRoute role="USER">
337- // <MyInterviews />
338- // </ProtectedRoute>
339- // }
340- // />
341-
342-
343- // {/* ================= INTERVIEW CALL (user and admin) =================
344- // No role on purpose: both the candidate and the recruiter (admin) must be able to open it.
345- // Without a login the person is sent to /login and comes back here afterwards.
346- // The backend (CallController) checks that the person really belongs to this interview. */}
347-
348- // <Route
349- // path="/interview/:id"
350- // element={
351- // <ProtectedRoute>
352- // <InterviewCall />
353- // </ProtectedRoute>
354- // }
355- // />
356-
357- // <Route
358- // path="/interview/:id/call"
359- // element={
360- // <ProtectedRoute>
361- // <InterviewCall />
362- // </ProtectedRoute>
363- // }
364- // />
365-
366-
367- // {/* ================= ADMIN PROTECTED ROUTES ================= */}
368-
369- // <Route
370- // path="/admin"
371- // element={
372- // <ProtectedRoute role="ADMIN">
373- // <AdminDashboard />
374- // </ProtectedRoute>
375- // }
376- // />
377-
378- // <Route
379- // path="/admin/jobs"
380- // element={
381- // <ProtectedRoute role="ADMIN">
382- // <AdminJobs />
383- // </ProtectedRoute>
384- // }
385- // />
386-
387- // <Route
388- // path="/admin/applications"
389- // element={
390- // <ProtectedRoute role="ADMIN">
391- // <AdminApplications />
392- // </ProtectedRoute>
393- // }
394- // />
395-
396- // <Route
397- // path="/admin/live"
398- // element={
399- // <ProtectedRoute role="ADMIN">
400- // <LiveInterviews />
401- // </ProtectedRoute>
402- // }
403- // />
404-
405-
406- // {/* ================= UNKNOWN ROUTES ================= */}
407-
408- // <Route
409- // path="*"
410- // element={<Navigate to="/" replace />}
411- // />
412-
413- // </Routes>
414- // );
415- // }
0 commit comments