1+ import { AbilityContext , AuthProvider } from '@/contexts' ;
2+ import { useAbility , useAuth } from '@/hooks' ;
13import NewUser from '@/pages/AdminDashboard/NewUser' ;
24import AdminDashboard from '@/pages/AdminDashboard/StaffDashboard' ;
35import QrPage from '@/pages/CompletedSurvey/QrPage' ;
@@ -13,7 +15,6 @@ import Signup from '@/pages/Signup/Signup';
1315import SurveyComponent from '@/pages/Survey/SurveyComponent' ;
1416import SurveyEntryDashboard from '@/pages/SurveyEntryDashboard/SurveyEntryDashboard' ;
1517import CssBaseline from '@mui/material/CssBaseline' ;
16- import { ProtectedRoute } from './components/ProtectedRoute' ;
1718import { ThemeProvider } from '@mui/material/styles' ;
1819import {
1920 Navigate ,
@@ -22,9 +23,8 @@ import {
2223 Routes
2324} from 'react-router-dom' ;
2425
26+ import { ProtectedRoute } from './components/ProtectedRoute' ;
2527import { muiTheme } from './theme/muiTheme' ;
26- import { AbilityContext , AuthProvider } from '@/contexts' ;
27- import { useAbility , useAuth } from '@/hooks' ;
2828
2929function App ( ) {
3030 const { isLoggedIn, handleLogin, handleLogout } = useAuth ( ) ;
@@ -48,111 +48,122 @@ function App() {
4848 < Route
4949 path = "/survey/:id/survey"
5050 element = {
51- < ProtectedRoute
52- isLoggedIn = { isLoggedIn }
53- children = { < SurveyComponent /> }
51+ < ProtectedRoute
52+ isLoggedIn = { isLoggedIn }
53+ children = { < SurveyComponent /> }
5454 />
5555 }
5656 />
5757 < Route path = "/signup" element = { < Signup /> } />
5858 < Route
5959 path = "/dashboard"
6060 element = {
61- < ProtectedRoute
62- isLoggedIn = { isLoggedIn }
63- children = { < LandingPage /> }
64- />
61+ < ProtectedRoute
62+ isLoggedIn = { isLoggedIn }
63+ children = { < LandingPage /> }
64+ />
6565 }
6666 />
6767 < Route
6868 path = "/survey"
6969 element = {
70- < ProtectedRoute
71- isLoggedIn = { isLoggedIn }
72- children = { < SurveyComponent /> }
70+ < ProtectedRoute
71+ isLoggedIn = { isLoggedIn }
72+ children = { < SurveyComponent /> }
7373 />
7474 }
7575 />
7676 < Route
7777 path = "/admin-dashboard"
7878 element = {
79- < ProtectedRoute
79+ < ProtectedRoute
8080 isLoggedIn = { isLoggedIn }
81- children = { < AdminDashboard /> }
81+ children = { < AdminDashboard /> }
8282 />
8383 }
8484 />
8585 < Route
8686 path = "/admin-edit-profile/:id"
8787 element = {
88- < ProtectedRoute
88+ < ProtectedRoute
8989 isLoggedIn = { isLoggedIn }
90- children = { < AdminEditProfile /> }
90+ children = { < AdminEditProfile /> }
9191 />
9292 }
9393 />
9494 < Route
9595 path = "/add-new-user"
9696 element = {
97- < ProtectedRoute
97+ < ProtectedRoute
9898 isLoggedIn = { isLoggedIn }
99- children = { < NewUser /> }
99+ children = { < NewUser /> }
100100 />
101101 }
102102 />
103103 < Route
104104 path = "/survey-entries"
105105 element = {
106- < ProtectedRoute isLoggedIn = { isLoggedIn }
107- children = { < SurveyEntryDashboard /> }
106+ < ProtectedRoute
107+ isLoggedIn = { isLoggedIn }
108+ children = { < SurveyEntryDashboard /> }
108109 />
109110 }
110111 />
111112 < Route
112113 path = "/qrcode"
113114 element = {
114- < ProtectedRoute isLoggedIn = { isLoggedIn }
115- children = { < QrPage /> }
115+ < ProtectedRoute
116+ isLoggedIn = { isLoggedIn }
117+ children = { < QrPage /> }
116118 />
117119 }
118120 />
119121 < Route
120122 path = "/past-entries"
121123 element = {
122- < ProtectedRoute isLoggedIn = { isLoggedIn }
123- children = { < PastEntries /> }
124+ < ProtectedRoute
125+ isLoggedIn = { isLoggedIn }
126+ children = { < PastEntries /> }
124127 />
125128 }
126129 />
127130 < Route
128131 path = "/survey/:id"
129132 element = {
130- < ProtectedRoute isLoggedIn = { isLoggedIn }
131- children = { < SurveyDetails /> }
133+ < ProtectedRoute
134+ isLoggedIn = { isLoggedIn }
135+ children = { < SurveyDetails /> }
132136 />
133137 }
134138 />
135139 < Route
136140 path = "/survey/:id/edit"
137141 element = {
138- < ProtectedRoute isLoggedIn = { isLoggedIn }
139- children = { < SurveyEdit /> }
142+ < ProtectedRoute
143+ isLoggedIn = { isLoggedIn }
144+ children = { < SurveyEdit /> }
140145 />
141146 }
142147 />
143148 < Route
144149 path = "/apply-referral"
145150 element = {
146- < ProtectedRoute isLoggedIn = { isLoggedIn }
147- children = { < ApplyReferral /> }
151+ < ProtectedRoute
152+ isLoggedIn = { isLoggedIn }
153+ children = { < ApplyReferral /> }
148154 />
149155 }
150156 />
151157 < Route
152158 path = "/view-profile"
153159 element = {
154- < ProtectedRoute isLoggedIn = { isLoggedIn }
155- children = { < ViewProfile onLogout = { handleLogout } /> } // TODO: rm onLogout when updating API fetching to useApi hook
160+ < ProtectedRoute
161+ isLoggedIn = { isLoggedIn }
162+ children = {
163+ < ViewProfile
164+ onLogout = { handleLogout }
165+ />
166+ } // TODO: rm onLogout when updating API fetching to useApi hook
156167 />
157168 }
158169 />
0 commit comments