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
|
@ -17,8 +17,11 @@
|
|||
@if (isLoggedIn) {
|
||||
<div
|
||||
class="text-white font-bold bg-deep-blue-contrast rounded-full px-4 py-2 text-sm hover:bg-deep-blue-contrast/80 hover:cursor-pointer hover:scale-105 transition-all active:scale-95 select-none duration-300"
|
||||
routerLink="/home"
|
||||
>
|
||||
<span>Balance: {{ balance() | currency: 'EUR' : 'symbol' : '1.2-2' }}</span>
|
||||
<span [class]="balance() < 0 ? 'text-accent-red' : ''">{{
|
||||
balance() | currency: 'EUR' : 'symbol' : '1.2-2'
|
||||
}}</span>
|
||||
</div>
|
||||
<button (click)="logout()" class="button-primary px-4 py-1.5">Abmelden</button>
|
||||
}
|
||||
|
|
|
@ -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