From 0619428e07053731baf71cfa065b0a1f6d46f135 Mon Sep 17 00:00:00 2001 From: eneller Date: Thu, 23 Jul 2026 20:19:53 +0200 Subject: [PATCH] feat: account switcher --- .../screens/screen-profile/screen-profile.html | 15 +++++++++++++-- .../app/screens/screen-profile/screen-profile.ts | 3 ++- client/src/app/services/api.ts | 7 +++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/client/src/app/screens/screen-profile/screen-profile.html b/client/src/app/screens/screen-profile/screen-profile.html index fc0c97f..6adbdae 100644 --- a/client/src/app/screens/screen-profile/screen-profile.html +++ b/client/src/app/screens/screen-profile/screen-profile.html @@ -4,9 +4,20 @@
+ {{this.api.loggedInUser.displayName}} +
+
+ +
+ @for (acc of this.api.ownedAccounts; track $index) { + + } +
+
+

-

{{ this.api.currentUser.displayName }}

-

{{ this.api.currentUser.id }}

{{ this.api.currentUser.balance | currency}}

diff --git a/client/src/app/screens/screen-profile/screen-profile.ts b/client/src/app/screens/screen-profile/screen-profile.ts index 744eaae..63110c7 100644 --- a/client/src/app/screens/screen-profile/screen-profile.ts +++ b/client/src/app/screens/screen-profile/screen-profile.ts @@ -3,10 +3,11 @@ import { Component, inject, OnInit, signal } from '@angular/core'; import { APIService } from '../../services/api'; import Transaction from '@model/transaction'; import { Router } from '@angular/router'; +import { NgbAccordionToggle, NgbDropdown, NgbDropdownItem, NgbDropdownMenu, NgbDropdownToggle } from "@ng-bootstrap/ng-bootstrap"; @Component({ selector: 'app-screen-profile', - imports: [CurrencyPipe, DatePipe, CommonModule], + imports: [CurrencyPipe, DatePipe, CommonModule, NgbDropdown, NgbDropdownMenu, NgbDropdownToggle, NgbDropdownItem], templateUrl: './screen-profile.html', styleUrl: './screen-profile.less', }) diff --git a/client/src/app/services/api.ts b/client/src/app/services/api.ts index 781f7ed..1698739 100644 --- a/client/src/app/services/api.ts +++ b/client/src/app/services/api.ts @@ -3,7 +3,6 @@ import { Injectable } from '@angular/core'; import { BehaviorSubject, catchError, map, Observable, of, tap } from 'rxjs'; import Transaction from '@model/transaction' import { SendRequest, SendResponse } from '@message/Send'; -import { TransactionsRequest } from '@message/Transactions'; import { LoginResponse } from '@message/Login'; import Account from '@model/user'; @@ -15,6 +14,8 @@ export class APIService { private isAuthenticatedSubject = new BehaviorSubject(false); isAuthenticated$ = this.isAuthenticatedSubject.asObservable(); + // data holding + loggedInUser!: Account; currentUser!: Account; ownedAccounts!: Account[]; @@ -25,8 +26,10 @@ export class APIService { tap({ next: (resp) => { this.isAuthenticatedSubject.next(true); - this.currentUser = resp.user; + this.loggedInUser = resp.user; + this.currentUser = this.loggedInUser; this.ownedAccounts = resp.ownedAccounts; + this.ownedAccounts.push(this.loggedInUser); }, error: () => this.isAuthenticatedSubject.next(false) })