@@ -115,18 +115,6 @@ GoRouter router(Ref ref) {
115115 );
116116 },
117117 routes: [
118- GoRoute (
119- name: AppRoute .leaderboard.name,
120- path: AppRoute .leaderboard.path,
121- pageBuilder: (context, state) => _buildTransitionPage (
122- key: state.pageKey,
123- child: DeferredWidget (
124- libraryKey: AppRoute .leaderboard.path,
125- libraryLoader: leaderboard.loadLibrary,
126- builder: (context) => leaderboard.LeaderboardView (),
127- ),
128- ),
129- ),
130118 GoRoute (
131119 name: AppRoute .calendar.name,
132120 path: AppRoute .calendar.path,
@@ -152,87 +140,112 @@ GoRouter router(Ref ref) {
152140 ),
153141 ),
154142
155- // Protected Admin routes
143+ // Protected Routes
156144 GoRoute (
157145 path: _protectedRoute,
158146 redirect: (context, state) {
159- if (! isLoggedIn && roles. hasPermission ( Role . ADMIN ) ) {
147+ if (! isLoggedIn) {
160148 return AppRoute .login.path;
161149 }
162150 return null ;
163151 },
164152 routes: [
165153 GoRoute (
166- name: AppRoute .setup .name,
167- path: AppRoute .setup .path,
154+ name: AppRoute .leaderboard .name,
155+ path: AppRoute .leaderboard .path,
168156 pageBuilder: (context, state) => _buildTransitionPage (
169157 key: state.pageKey,
170158 child: DeferredWidget (
171- libraryKey: AppRoute .setup .path,
172- libraryLoader: setup .loadLibrary,
173- builder: (context) => setup. SetupView (),
159+ libraryKey: AppRoute .leaderboard .path,
160+ libraryLoader: leaderboard .loadLibrary,
161+ builder: (context) => leaderboard. LeaderboardView (),
174162 ),
175163 ),
176164 ),
165+
166+ // Protected Admin routes
177167 GoRoute (
178- name: AppRoute .users.name,
179- path: AppRoute .users.path,
180- pageBuilder: (context, state) => _buildTransitionPage (
181- key: state.pageKey,
182- child: DeferredWidget (
183- libraryKey: AppRoute .users.path,
184- libraryLoader: users.loadLibrary,
185- builder: (context) => users.UsersView (),
168+ path: '/admin' ,
169+ redirect: (context, state) {
170+ if (! isLoggedIn && roles.hasPermission (Role .ADMIN )) {
171+ return AppRoute .login.path;
172+ }
173+ return null ;
174+ },
175+ routes: [
176+ GoRoute (
177+ name: AppRoute .setup.name,
178+ path: AppRoute .setup.path,
179+ pageBuilder: (context, state) => _buildTransitionPage (
180+ key: state.pageKey,
181+ child: DeferredWidget (
182+ libraryKey: AppRoute .setup.path,
183+ libraryLoader: setup.loadLibrary,
184+ builder: (context) => setup.SetupView (),
185+ ),
186+ ),
186187 ),
187- ),
188- ) ,
189- GoRoute (
190- name : AppRoute .team.name,
191- path : AppRoute .team.path ,
192- pageBuilder : (context, state) => _buildTransitionPage (
193- key : state.pageKey ,
194- child : DeferredWidget (
195- libraryKey : AppRoute .team.path ,
196- libraryLoader : team.loadLibrary ,
197- builder : (context) => team. TeamView ( ),
188+ GoRoute (
189+ name : AppRoute .users.name ,
190+ path : AppRoute .users.path,
191+ pageBuilder : (context, state) => _buildTransitionPage (
192+ key : state.pageKey ,
193+ child : DeferredWidget (
194+ libraryKey : AppRoute .users.path ,
195+ libraryLoader : users.loadLibrary,
196+ builder : (context) => users. UsersView () ,
197+ ) ,
198+ ),
198199 ),
199- ),
200- ) ,
201- GoRoute (
202- name : AppRoute .sessions.name,
203- path : AppRoute .sessions.path ,
204- pageBuilder : (context, state) => _buildTransitionPage (
205- key : state.pageKey ,
206- child : DeferredWidget (
207- libraryKey : AppRoute .sessions.path ,
208- libraryLoader : sessions.loadLibrary ,
209- builder : (context) => sessions. SessionView ( ),
200+ GoRoute (
201+ name : AppRoute .team.name ,
202+ path : AppRoute .team.path,
203+ pageBuilder : (context, state) => _buildTransitionPage (
204+ key : state.pageKey ,
205+ child : DeferredWidget (
206+ libraryKey : AppRoute .team.path ,
207+ libraryLoader : team.loadLibrary,
208+ builder : (context) => team. TeamView () ,
209+ ) ,
210+ ),
210211 ),
211- ),
212- ) ,
213- GoRoute (
214- name : AppRoute .locations.name,
215- path : AppRoute .locations.path ,
216- pageBuilder : (context, state) => _buildTransitionPage (
217- key : state.pageKey ,
218- child : DeferredWidget (
219- libraryKey : AppRoute .locations.path ,
220- libraryLoader : locations.loadLibrary ,
221- builder : (context) => locations. LocationsView ( ),
212+ GoRoute (
213+ name : AppRoute .sessions.name ,
214+ path : AppRoute .sessions.path,
215+ pageBuilder : (context, state) => _buildTransitionPage (
216+ key : state.pageKey ,
217+ child : DeferredWidget (
218+ libraryKey : AppRoute .sessions.path ,
219+ libraryLoader : sessions.loadLibrary,
220+ builder : (context) => sessions. SessionView () ,
221+ ) ,
222+ ),
222223 ),
223- ),
224- ) ,
225- GoRoute (
226- name : AppRoute .stats.name,
227- path : AppRoute .stats.path ,
228- pageBuilder : (context, state) => _buildTransitionPage (
229- key : state.pageKey ,
230- child : DeferredWidget (
231- libraryKey : AppRoute .stats.path ,
232- libraryLoader : stats.loadLibrary ,
233- builder : (context) => stats. StatsView ( ),
224+ GoRoute (
225+ name : AppRoute .locations.name ,
226+ path : AppRoute .locations.path,
227+ pageBuilder : (context, state) => _buildTransitionPage (
228+ key : state.pageKey ,
229+ child : DeferredWidget (
230+ libraryKey : AppRoute .locations.path ,
231+ libraryLoader : locations.loadLibrary,
232+ builder : (context) => locations. LocationsView () ,
233+ ) ,
234+ ),
234235 ),
235- ),
236+ GoRoute (
237+ name: AppRoute .stats.name,
238+ path: AppRoute .stats.path,
239+ pageBuilder: (context, state) => _buildTransitionPage (
240+ key: state.pageKey,
241+ child: DeferredWidget (
242+ libraryKey: AppRoute .stats.path,
243+ libraryLoader: stats.loadLibrary,
244+ builder: (context) => stats.StatsView (),
245+ ),
246+ ),
247+ ),
248+ ],
236249 ),
237250 ],
238251 ),
0 commit comments