-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client): improve stats navigation
- Loading branch information
Showing
8 changed files
with
64 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Note: this file contains all types and constants related to stats tabs | ||
|
||
import { InputSignal } from '@angular/core'; | ||
|
||
export type SelectedStatsTab = 'summary' | 'details'; | ||
|
||
/** | ||
* List of tabs as they appear in the user interface | ||
*/ | ||
export const ORDERED_STATS_TABS = ['summary' satisfies SelectedStatsTab, 'details' satisfies SelectedStatsTab] as const; | ||
|
||
export const STATS_TAB_PARAM = 'tab'; | ||
|
||
export type StatsTabData = Record<typeof STATS_TAB_PARAM, InputSignal<SelectedStatsTab>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { inject } from '@angular/core'; | ||
import { CanActivateFn, RedirectCommand, Router } from '@angular/router'; | ||
import { ORDERED_STATS_TABS, STATS_TAB_PARAM } from './stats-tab'; | ||
|
||
export const statsGuard: CanActivateFn = (route) => { | ||
if (ORDERED_STATS_TABS.includes(route.params[STATS_TAB_PARAM])) { | ||
return true; | ||
} | ||
return new RedirectCommand(inject(Router).parseUrl('/stats')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Routes } from '@angular/router'; | ||
import { STATS_TAB_PARAM } from './stats-tab'; | ||
import { StatsComponent } from './stats.component'; | ||
import { statsGuard } from './stats.guard'; | ||
|
||
export default [ | ||
{ | ||
path: '', | ||
pathMatch: 'full', | ||
redirectTo: '/stats/summary', | ||
}, | ||
{ | ||
path: `:${STATS_TAB_PARAM}`, | ||
component: StatsComponent, | ||
canActivate: [statsGuard], | ||
title: 'FeedZback - Stats', | ||
}, | ||
] satisfies Routes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters