@@ -38,6 +38,8 @@ const enhancedEmployerView = {
3838 ]
3939} ;
4040
41+ import ProtectedRoute from "./components/ProtectedRoute" ;
42+
4143const App = ( ) => {
4244 const [ selectedRole , setSelectedRole ] = useState (
4345 localStorage . getItem ( 'userRole' ) ||
@@ -75,7 +77,7 @@ const App = () => {
7577
7678 // Check if Dynamic Labs environment ID is configured
7779 const dynamicEnvId = import . meta. env . VITE_DYNAMIC_ENV_ID ;
78-
80+
7981 if ( ! dynamicEnvId ) {
8082 console . error ( 'VITE_DYNAMIC_ENV_ID is not configured. Please set this environment variable.' ) ;
8183 return (
@@ -136,32 +138,90 @@ const App = () => {
136138 } }
137139 >
138140 < div >
139- < Routes >
140- { /* Common Routes */ }
141- < Route path = "/" element = { < LandingPage /> } />
142- < Route path = "/about-us" element = { < AboutPage /> } />
143- < Route path = "/user-profile" element = { < UserProfile /> } />
144- < Route path = "/job-details/:id" element = { < JobDetails /> } />
145-
146- { /* Employee Routes */ }
147- < Route path = "/employeeDashboard" element = { < EmployeeDashboard /> } />
148- < Route path = "/employee-profile" element = { < EmployeeProfile /> } />
149- < Route path = "/employee-jobs" element = { < EmployeeJobsPage /> } />
150-
151- { /* Employer Routes */ }
152- < Route path = "/employerDashboard" element = { < EmployerDashboard /> } />
153- < Route path = "/employer-profile" element = { < EmployerProfile /> } />
154- < Route path = "/job" element = { < Job /> } />
155- < Route path = "/view-employees" element = { < EmployerJobPortal /> } />
156- < Route path = "/view-open-contracts" element = { < OpenContracts /> } />
157- < Route path = "/review-applications" element = { < ReviewApplications /> } />
158- < Route path = "/review-completed-contracts" element = { < ReviewCompletedContracts /> } />
159- < Route path = "/dispute" element = { < Dispute /> } />
160- < Route path = "/closed-contracts" element = { < ClosedContracts /> } />
161-
162- { /* 404 - Must be last */ }
163- < Route path = "*" element = { < h1 > 404 - Not Found</ h1 > } />
164- </ Routes >
141+ < Routes >
142+ { /* Public Routes */ }
143+ < Route path = "/" element = { < LandingPage /> } />
144+ < Route path = "/about-us" element = { < AboutPage /> } />
145+
146+ { /* Protected Routes */ }
147+ < Route path = "/user-profile" element = {
148+ < ProtectedRoute >
149+ < UserProfile />
150+ </ ProtectedRoute >
151+ } />
152+ < Route path = "/job-details/:id" element = {
153+ < ProtectedRoute >
154+ < JobDetails />
155+ </ ProtectedRoute >
156+ } />
157+
158+ { /* Employee Routes */ }
159+ < Route path = "/employeeDashboard" element = {
160+ < ProtectedRoute >
161+ < EmployeeDashboard />
162+ </ ProtectedRoute >
163+ } />
164+ < Route path = "/employee-profile" element = {
165+ < ProtectedRoute >
166+ < EmployeeProfile />
167+ </ ProtectedRoute >
168+ } />
169+ < Route path = "/employee-jobs" element = {
170+ < ProtectedRoute >
171+ < EmployeeJobsPage />
172+ </ ProtectedRoute >
173+ } />
174+
175+ { /* Employer Routes */ }
176+ < Route path = "/employerDashboard" element = {
177+ < ProtectedRoute >
178+ < EmployerDashboard />
179+ </ ProtectedRoute >
180+ } />
181+ < Route path = "/employer-profile" element = {
182+ < ProtectedRoute >
183+ < EmployerProfile />
184+ </ ProtectedRoute >
185+ } />
186+ < Route path = "/job" element = {
187+ < ProtectedRoute >
188+ < Job />
189+ </ ProtectedRoute >
190+ } />
191+ < Route path = "/view-employees" element = {
192+ < ProtectedRoute >
193+ < EmployerJobPortal />
194+ </ ProtectedRoute >
195+ } />
196+ < Route path = "/view-open-contracts" element = {
197+ < ProtectedRoute >
198+ < OpenContracts />
199+ </ ProtectedRoute >
200+ } />
201+ < Route path = "/review-applications" element = {
202+ < ProtectedRoute >
203+ < ReviewApplications />
204+ </ ProtectedRoute >
205+ } />
206+ < Route path = "/review-completed-contracts" element = {
207+ < ProtectedRoute >
208+ < ReviewCompletedContracts />
209+ </ ProtectedRoute >
210+ } />
211+ < Route path = "/dispute" element = {
212+ < ProtectedRoute >
213+ < Dispute />
214+ </ ProtectedRoute >
215+ } />
216+ < Route path = "/closed-contracts" element = {
217+ < ProtectedRoute >
218+ < ClosedContracts />
219+ </ ProtectedRoute >
220+ } />
221+
222+ { /* 404 - Must be last */ }
223+ < Route path = "*" element = { < h1 > 404 - Not Found</ h1 > } />
224+ </ Routes >
165225 </ div >
166226 </ DynamicContextProvider >
167227 ) ;
0 commit comments