refactor(routes): simplify component loading syntax

This commit is contained in:
Constantin Simonis 2025-05-21 11:54:55 +02:00
commit e5f8d6ce10
No known key found for this signature in database
GPG key ID: 3878FF77C24AF4D2
5 changed files with 46 additions and 53 deletions

View file

@ -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',
path: 'game',
children: [
{
path: 'blackjack',
loadComponent: () => import('./feature/game/blackjack/blackjack.component'),
canActivate: [authGuard],
},
{
path: 'game/coinflip',
path: 'coinflip',
loadComponent: () => import('./feature/game/coinflip/coinflip.component'),
canActivate: [authGuard],
},
{
path: 'game/slots',
path: 'slots',
loadComponent: () => import('./feature/game/slots/slots.component'),
canActivate: [authGuard],
},
{
path: 'game/lootboxes',
path: 'lootboxes',
loadComponent: () =>
import('./feature/lootboxes/lootbox-selection/lootbox-selection.component'),
canActivate: [authGuard],
},
children: [
{
path: 'game/lootboxes/open/:id',
loadComponent: () => import('./feature/lootboxes/lootbox-opening/lootbox-opening.component'),
path: '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),
path: 'dice',
loadComponent: () => import('./feature/game/dice/dice.component'),
canActivate: [authGuard],
},
],
},
];

View file

@ -19,7 +19,7 @@ import { Oauth2Service } from './oauth2.service';
</div>
`,
})
export class OAuth2CallbackComponent implements OnInit {
export default class OAuth2CallbackComponent implements OnInit {
error: Signal<string> = computed(() => this.oauthService.error());
private route: ActivatedRoute = inject(ActivatedRoute);

View file

@ -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('');

View file

@ -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);

View file

@ -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);