This repository has been archived on 2025-06-18. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
casino/frontend/src/app/shared/components/navbar/navbar.component.ts
Constantin Simonis 88c2f49b03
All checks were successful
CI / Get Changed Files (pull_request) Successful in 7s
CI / Checkstyle Main (pull_request) Has been skipped
CI / Docker backend validation (pull_request) Successful in 9s
CI / oxlint (pull_request) Successful in 24s
CI / Docker frontend validation (pull_request) Successful in 37s
CI / eslint (pull_request) Successful in 29s
CI / prettier (pull_request) Successful in 28s
CI / test-build (pull_request) Successful in 31s
style(navbar): format import statements and arrow function
2025-05-07 17:26:44 +02:00

48 lines
1.2 KiB
TypeScript

import {
ChangeDetectionStrategy,
Component,
inject,
OnDestroy,
OnInit,
signal,
} from '@angular/core';
import { RouterModule } from '@angular/router';
import { AuthService } from '@service/auth.service';
import { Subscription } from 'rxjs';
import { AnimatedNumberComponent } from '@blackjack/components/animated-number/animated-number.component';
@Component({
selector: 'app-navbar',
templateUrl: './navbar.component.html',
standalone: true,
imports: [RouterModule, AnimatedNumberComponent],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NavbarComponent implements OnInit, OnDestroy {
isMenuOpen = false;
private authService: AuthService = inject(AuthService);
isLoggedIn = this.authService.isLoggedIn();
private authSubscription!: Subscription;
public balance = signal(0);
ngOnInit() {
this.authSubscription = this.authService.userSubject.subscribe({
next: (user) => {
this.balance.set(user?.balance ?? 0);
},
});
}
ngOnDestroy() {
this.authSubscription.unsubscribe();
}
logout() {
this.authService.logout();
}
toggleMenu() {
this.isMenuOpen = !this.isMenuOpen;
}
}