From e5f8d6ce106166b6a18e8e780ce79fd757e6b9d7 Mon Sep 17 00:00:00 2001 From: Constantin Simonis Date: Wed, 21 May 2025 11:54:55 +0200 Subject: [PATCH 1/2] refactor(routes): simplify component loading syntax --- frontend/src/app/app.routes.ts | 91 +++++++++---------- .../auth/oauth2/oauth2-callback.component.ts | 2 +- .../recover-password.component.ts | 2 +- .../verify-email/verify-email.component.ts | 2 +- .../app/feature/game/dice/dice.component.ts | 2 +- 5 files changed, 46 insertions(+), 53 deletions(-) diff --git a/frontend/src/app/app.routes.ts b/frontend/src/app/app.routes.ts index 44c342a..88f4fe1 100644 --- a/frontend/src/app/app.routes.ts +++ b/frontend/src/app/app.routes.ts @@ -14,75 +14,68 @@ export const routes: Routes = [ }, { path: 'verify', - loadComponent: () => - import('./feature/auth/verify-email/verify-email.component').then( - (m) => m.VerifyEmailComponent - ), + loadComponent: () => import('./feature/auth/verify-email/verify-email.component'), }, { path: 'recover-password', - loadComponent: () => - import('./feature/auth/recover-password/recover-password.component').then( - (m) => m.RecoverPasswordComponent - ), + loadComponent: () => import('./feature/auth/recover-password/recover-password.component'), }, { path: 'reset-password', - loadComponent: () => - import('./feature/auth/recover-password/recover-password.component').then( - (m) => m.RecoverPasswordComponent - ), + loadComponent: () => import('./feature/auth/recover-password/recover-password.component'), }, { path: 'oauth2/callback', children: [ { path: 'github', - loadComponent: () => - import('./feature/auth/oauth2/oauth2-callback.component').then( - (m) => m.OAuth2CallbackComponent - ), + loadComponent: () => import('./feature/auth/oauth2/oauth2-callback.component'), data: { provider: 'github' }, }, { path: 'google', - loadComponent: () => - import('./feature/auth/oauth2/oauth2-callback.component').then( - (m) => m.OAuth2CallbackComponent - ), + loadComponent: () => import('./feature/auth/oauth2/oauth2-callback.component'), data: { provider: 'google' }, }, ], }, { - path: 'game/blackjack', - loadComponent: () => import('./feature/game/blackjack/blackjack.component'), - canActivate: [authGuard], - }, - { - path: 'game/coinflip', - loadComponent: () => import('./feature/game/coinflip/coinflip.component'), - canActivate: [authGuard], - }, - { - path: 'game/slots', - loadComponent: () => import('./feature/game/slots/slots.component'), - canActivate: [authGuard], - }, - { - path: 'game/lootboxes', - loadComponent: () => - import('./feature/lootboxes/lootbox-selection/lootbox-selection.component'), - canActivate: [authGuard], - }, - { - path: 'game/lootboxes/open/:id', - loadComponent: () => import('./feature/lootboxes/lootbox-opening/lootbox-opening.component'), - canActivate: [authGuard], - }, - { - path: 'game/dice', - loadComponent: () => import('./feature/game/dice/dice.component').then((m) => m.DiceComponent), - canActivate: [authGuard], + path: 'game', + children: [ + { + path: 'blackjack', + loadComponent: () => import('./feature/game/blackjack/blackjack.component'), + canActivate: [authGuard], + }, + { + path: 'coinflip', + loadComponent: () => import('./feature/game/coinflip/coinflip.component'), + canActivate: [authGuard], + }, + { + path: 'slots', + loadComponent: () => import('./feature/game/slots/slots.component'), + canActivate: [authGuard], + }, + { + path: 'lootboxes', + loadComponent: () => + import('./feature/lootboxes/lootbox-selection/lootbox-selection.component'), + canActivate: [authGuard], + children: [ + { + path: 'open/:id', + loadComponent: () => + import('./feature/lootboxes/lootbox-opening/lootbox-opening.component'), + canActivate: [authGuard], + }, + ], + }, + { + path: 'dice', + loadComponent: () => import('./feature/game/dice/dice.component'), + canActivate: [authGuard], + }, + ], }, ]; diff --git a/frontend/src/app/feature/auth/oauth2/oauth2-callback.component.ts b/frontend/src/app/feature/auth/oauth2/oauth2-callback.component.ts index ebd2688..9c4bcf3 100644 --- a/frontend/src/app/feature/auth/oauth2/oauth2-callback.component.ts +++ b/frontend/src/app/feature/auth/oauth2/oauth2-callback.component.ts @@ -19,7 +19,7 @@ import { Oauth2Service } from './oauth2.service'; `, }) -export class OAuth2CallbackComponent implements OnInit { +export default class OAuth2CallbackComponent implements OnInit { error: Signal = computed(() => this.oauthService.error()); private route: ActivatedRoute = inject(ActivatedRoute); diff --git a/frontend/src/app/feature/auth/recover-password/recover-password.component.ts b/frontend/src/app/feature/auth/recover-password/recover-password.component.ts index 905f200..89f5d96 100644 --- a/frontend/src/app/feature/auth/recover-password/recover-password.component.ts +++ b/frontend/src/app/feature/auth/recover-password/recover-password.component.ts @@ -10,7 +10,7 @@ import { AuthService } from '@service/auth.service'; imports: [CommonModule, ReactiveFormsModule, RouterModule], templateUrl: './recover-password.component.html', }) -export class RecoverPasswordComponent implements OnInit { +export default class RecoverPasswordComponent implements OnInit { emailForm: FormGroup; resetPasswordForm: FormGroup; errorMessage = signal(''); diff --git a/frontend/src/app/feature/auth/verify-email/verify-email.component.ts b/frontend/src/app/feature/auth/verify-email/verify-email.component.ts index 6e04877..54f4c2f 100644 --- a/frontend/src/app/feature/auth/verify-email/verify-email.component.ts +++ b/frontend/src/app/feature/auth/verify-email/verify-email.component.ts @@ -7,7 +7,7 @@ import { AuthService } from '@service/auth.service'; imports: [], templateUrl: './verify-email.component.html', }) -export class VerifyEmailComponent implements OnInit { +export default class VerifyEmailComponent implements OnInit { route: ActivatedRoute = inject(ActivatedRoute); router: Router = inject(Router); authService: AuthService = inject(AuthService); diff --git a/frontend/src/app/feature/game/dice/dice.component.ts b/frontend/src/app/feature/game/dice/dice.component.ts index fe50cf6..b4ced3f 100644 --- a/frontend/src/app/feature/game/dice/dice.component.ts +++ b/frontend/src/app/feature/game/dice/dice.component.ts @@ -24,7 +24,7 @@ type DiceFormGroup = FormGroup<{ imports: [CommonModule, ReactiveFormsModule], templateUrl: './dice.component.html', }) -export class DiceComponent implements OnInit { +export default class DiceComponent implements OnInit { private readonly formBuilder = inject(FormBuilder); private readonly diceService = inject(DiceService); private readonly userService = inject(UserService); From 1514f18d58ff00d5a059ccb27621e5d6c81d1098 Mon Sep 17 00:00:00 2001 From: Constantin Simonis Date: Wed, 21 May 2025 12:05:09 +0200 Subject: [PATCH 2/2] refactor: update import paths for component files --- frontend/src/app/app.component.ts | 10 +++++----- frontend/src/app/feature/landing/landing.component.ts | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/app.component.ts b/frontend/src/app/app.component.ts index a9ce6d0..7499296 100644 --- a/frontend/src/app/app.component.ts +++ b/frontend/src/app/app.component.ts @@ -1,12 +1,12 @@ import { Component, HostListener, inject, signal } from '@angular/core'; import { RouterOutlet } from '@angular/router'; -import { NavbarComponent } from './shared/components/navbar/navbar.component'; -import { FooterComponent } from './shared/components/footer/footer.component'; +import { NavbarComponent } from '@shared/components/navbar/navbar.component'; +import { FooterComponent } from '@shared/components/footer/footer.component'; import { LoginComponent } from './feature/auth/login/login.component'; import { RegisterComponent } from './feature/auth/register/register.component'; -import { RecoverPasswordComponent } from './feature/auth/recover-password/recover-password.component'; -import { PlaySoundDirective } from './shared/directives/play-sound.directive'; -import { SoundInitializerService } from './shared/services/sound-initializer.service'; +import RecoverPasswordComponent from './feature/auth/recover-password/recover-password.component'; +import { PlaySoundDirective } from '@shared/directives/play-sound.directive'; +import { SoundInitializerService } from '@shared/services/sound-initializer.service'; @Component({ selector: 'app-root', diff --git a/frontend/src/app/feature/landing/landing.component.ts b/frontend/src/app/feature/landing/landing.component.ts index aa1867e..d354fa4 100644 --- a/frontend/src/app/feature/landing/landing.component.ts +++ b/frontend/src/app/feature/landing/landing.component.ts @@ -11,7 +11,8 @@ import { ActivatedRoute, RouterLink } from '@angular/router'; import { AuthService } from '@service/auth.service'; import { LoginComponent } from '../auth/login/login.component'; import { RegisterComponent } from '../auth/register/register.component'; -import { RecoverPasswordComponent } from '../auth/recover-password/recover-password.component'; +import '../auth/recover-password/recover-password.component'; +import RecoverPasswordComponent from '../auth/recover-password/recover-password.component'; @Component({ selector: 'app-landing-page',