Merge branch 'main' into feature/authentik
Some checks failed
Some checks failed
This commit is contained in:
commit
d7fe0e3965
56 changed files with 2782 additions and 602 deletions
|
@ -1,8 +1,16 @@
|
|||
import { ChangeDetectionStrategy, Component, inject, OnInit, signal } from '@angular/core';
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
inject,
|
||||
OnInit,
|
||||
OnDestroy,
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { UserService } from '../../../service/user.service';
|
||||
import { CurrencyPipe } from '@angular/common';
|
||||
import { AuthService } from '../../../service/auth.service';
|
||||
import { CurrencyPipe } from '@angular/common';
|
||||
import { UserService } from '@service/user.service';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'app-navbar',
|
||||
|
@ -11,22 +19,27 @@ import { AuthService } from '../../../service/auth.service';
|
|||
imports: [RouterModule, CurrencyPipe],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class NavbarComponent implements OnInit {
|
||||
export class NavbarComponent implements OnInit, OnDestroy {
|
||||
isMenuOpen = false;
|
||||
private authService: AuthService = inject(AuthService);
|
||||
isLoggedIn = this.authService.isLoggedIn();
|
||||
|
||||
private userService = inject(UserService);
|
||||
private user = this.userService.getCurrentUser();
|
||||
|
||||
private userSubscription: Subscription | undefined;
|
||||
public balance = signal(0);
|
||||
|
||||
ngOnInit() {
|
||||
this.user.subscribe((user) => {
|
||||
this.userSubscription = this.userService.currentUser$.subscribe((user) => {
|
||||
this.balance.set(user?.balance ?? 0);
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.userSubscription) {
|
||||
this.userSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
login() {
|
||||
try {
|
||||
this.authService.login();
|
||||
|
|
Reference in a new issue