From e37dcecd3fef41bc9ea17ce7a793aa1376946154 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 2 Apr 2025 16:20:37 +0200 Subject: [PATCH] refactor: update imports and type definitions in services --- frontend/src/app/feature/deposit/deposit.component.ts | 4 ++-- .../app/feature/game/blackjack/blackjack.component.ts | 1 + frontend/src/app/service/auth.service.ts | 6 +++--- frontend/src/app/service/user.service.ts | 11 ++++++----- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/frontend/src/app/feature/deposit/deposit.component.ts b/frontend/src/app/feature/deposit/deposit.component.ts index 6cbae07..834a2e4 100644 --- a/frontend/src/app/feature/deposit/deposit.component.ts +++ b/frontend/src/app/feature/deposit/deposit.component.ts @@ -17,7 +17,7 @@ import { import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; import { loadStripe, Stripe } from '@stripe/stripe-js'; import { debounceTime } from 'rxjs'; -import { NgIf } from '@angular/common'; +import { CommonModule } from '@angular/common'; import gsap from 'gsap'; import { DepositService } from '@service/deposit.service'; import { environment } from '@environments/environment'; @@ -26,7 +26,7 @@ import { ModalAnimationService } from '@shared/services/modal-animation.service' @Component({ selector: 'app-deposit', standalone: true, - imports: [ReactiveFormsModule, NgIf], + imports: [ReactiveFormsModule, CommonModule], templateUrl: './deposit.component.html', changeDetection: ChangeDetectionStrategy.OnPush, }) diff --git a/frontend/src/app/feature/game/blackjack/blackjack.component.ts b/frontend/src/app/feature/game/blackjack/blackjack.component.ts index 702776e..67ce15b 100644 --- a/frontend/src/app/feature/game/blackjack/blackjack.component.ts +++ b/frontend/src/app/feature/game/blackjack/blackjack.component.ts @@ -1,6 +1,7 @@ import { ChangeDetectionStrategy, Component, inject, signal, OnInit } from '@angular/core'; import { CommonModule } from '@angular/common'; import { Router } from '@angular/router'; +// Importing components used in templates import { PlayingCardComponent } from './components/playing-card/playing-card.component'; import { DealerHandComponent } from './components/dealer-hand/dealer-hand.component'; import { PlayerHandComponent } from './components/player-hand/player-hand.component'; diff --git a/frontend/src/app/service/auth.service.ts b/frontend/src/app/service/auth.service.ts index aaf7c8d..158ea5f 100644 --- a/frontend/src/app/service/auth.service.ts +++ b/frontend/src/app/service/auth.service.ts @@ -158,8 +158,8 @@ export class AuthService { } } - private processUserProfile(profile: Record) { - this.fromUserProfile(profile).subscribe({ + private processUserProfile(profile: unknown) { + this.fromUserProfile(profile as Record).subscribe({ next: (user) => { console.log('User created/retrieved from backend:', user); this.user = user; @@ -225,7 +225,7 @@ export class AuthService { return this.oauthService.hasValidAccessToken(); } - private fromUserProfile(profile: object) { + private fromUserProfile(profile: Record) { return this.userService.getOrCreateUser(profile); } diff --git a/frontend/src/app/service/user.service.ts b/frontend/src/app/service/user.service.ts index aba8145..3c64e34 100644 --- a/frontend/src/app/service/user.service.ts +++ b/frontend/src/app/service/user.service.ts @@ -47,12 +47,13 @@ export class UserService { console.log('Full authentik profile:', profile); // Authentik format might differ from Keycloak // Check different possible locations for the ID and username - const id = profile.info?.sub || profile['sub']; + const info = profile['info'] as Record | undefined; + const id = info?.['sub'] as string || profile['sub'] as string; const username = - profile.info?.preferred_username || - profile['preferred_username'] || - profile['email'] || - profile['name']; + info?.['preferred_username'] as string || + profile['preferred_username'] as string || + profile['email'] as string || + profile['name'] as string; if (!id || !username) { console.error('Could not extract user ID or username from profile', profile);