@@ -4,6 +4,7 @@ import logoImage from '/assets/images/logo/logomark-color.svg';
44import type AuthenticatorService from 'codecrafters-frontend/services/authenticator' ;
55import type ContainerWidthService from 'codecrafters-frontend/services/container-width' ;
66import type FeatureFlagsService from 'codecrafters-frontend/services/feature-flags' ;
7+ import type PreferredLanguageLeaderboardService from 'codecrafters-frontend/services/preferred-language-leaderboard' ;
78import type RouterService from '@ember/routing/router-service' ;
89import type VersionTrackerService from 'codecrafters-frontend/services/version-tracker' ;
910import type { SafeString } from '@ember/template/-private/handlebars' ;
@@ -23,13 +24,21 @@ export default class Header extends Component<Signature> {
2324 @service declare authenticator : AuthenticatorService ;
2425 @service declare containerWidth : ContainerWidthService ;
2526 @service declare featureFlags : FeatureFlagsService ;
27+ @service declare preferredLanguageLeaderboard : PreferredLanguageLeaderboardService ;
2628 @service declare router : RouterService ;
2729 @service declare versionTracker : VersionTrackerService ;
2830
2931 @tracked mobileMenuIsExpanded = false ;
3032 @tracked floatingBarStyle : SafeString = htmlSafe ( 'left: 0px; width: 0px; opacity: 0;' ) ;
3133 @tracked floatingBarContainer : HTMLElement | null = null ;
3234
35+ constructor ( owner : unknown , args : object ) {
36+ super ( owner , args ) ;
37+
38+ // This can't be in instance-initializers since it depends on the authenticator service
39+ this . preferredLanguageLeaderboard . onBoot ( ) ;
40+ }
41+
3342 get activeDiscountForYearlyPlan ( ) : PromotionalDiscountModel | null {
3443 return this . currentUser ?. activeDiscountForYearlyPlan || null ;
3544 }
@@ -38,7 +47,7 @@ export default class Header extends Component<Signature> {
3847 return this . authenticator . currentUser ;
3948 }
4049
41- get links ( ) : { text : string ; route : string ; type : 'route' | 'link' } [ ] {
50+ get links ( ) : { text : string ; route : string ; type : 'route' | 'link' ; routeParams ?: string [ ] } [ ] {
4251 if ( this . currentUser ) {
4352 return this . linksForAuthenticatedUser ;
4453 } else {
@@ -54,12 +63,21 @@ export default class Header extends Component<Signature> {
5463 ] ;
5564 }
5665
57- get linksForAuthenticatedUser ( ) : { text : string ; route : string ; type : 'route' | 'link' } [ ] {
58- const links : { text : string ; route : string ; type : 'route' | 'link' } [ ] = [
66+ get linksForAuthenticatedUser ( ) : { text : string ; route : string ; type : 'route' | 'link' ; routeParams ?: string [ ] } [ ] {
67+ const links : { text : string ; route : string ; type : 'route' | 'link' ; routeParams ?: string [ ] } [ ] = [
5968 { text : 'Catalog' , route : 'catalog' , type : 'route' } ,
6069 { text : 'Roadmap' , route : 'roadmap' , type : 'route' } ,
6170 ] ;
6271
72+ if ( this . featureFlags . shouldSeeLeaderboard ) {
73+ links . push ( {
74+ text : 'Leaderboard' ,
75+ route : 'leaderboard' ,
76+ type : 'route' ,
77+ routeParams : [ this . preferredLanguageLeaderboard . defaultLanguageSlug ] ,
78+ } ) ;
79+ }
80+
6381 return links ;
6482 }
6583
0 commit comments