source: bus-n-go-pavel-216049/bus-n-go-frontend/src/app/components/navigation/navigation.component.ts

Last change on this file was baf4cc4, checked in by ppaunovski <paunovskipavel@…>, 3 months ago

split group project and individual project into two separate folders

  • Property mode set to 100644
File size: 1.6 KB
Line 
1import {Component, OnInit} from '@angular/core';
2import {AuthService} from "../../services/auth/auth.service";
3import {Router, RouterLink} from "@angular/router";
4import {switchMap} from "rxjs";
5import {UserResponse} from "../../model/responses/UserResponse";
6import {UserService} from "../../services/user/user.service";
7import {MatMenuModule} from '@angular/material/menu';
8import {MatButtonModule} from '@angular/material/button';
9
10@Component({
11 selector: 'app-navigation',
12 standalone: true,
13 imports: [
14 RouterLink, MatButtonModule, MatMenuModule
15 ],
16 templateUrl: './navigation.component.html',
17})
18export class NavigationComponent implements OnInit {
19
20 constructor(
21 private _authService: AuthService,
22 private _router: Router,
23 private _userService: UserService,
24 ) {
25 }
26
27 user: UserResponse | undefined
28
29 ngOnInit(): void {
30 this._authService.refreshAuth$.pipe(
31 switchMap(auth => this._userService.getUser())
32 ).subscribe({
33 next: user => {
34 console.log(user)
35 this.user = user
36 },
37 error: err => {
38 this.user = undefined
39 }
40 })
41
42 this._userService.getUser().subscribe({
43 next: user => {
44 this.user = user
45 }
46 })
47 }
48
49 isMenuOpen = false;
50 isIconMenuOpen = false;
51
52 changeMenuState() {
53 console.log('changeMenuState');
54 this.isMenuOpen = !this.isMenuOpen;
55 }
56
57 changeIconMenuState() {
58 console.log('changeIconMenuState');
59 this.isIconMenuOpen = !this.isIconMenuOpen;
60 }
61
62 signOut() {
63 sessionStorage.clear()
64 this._authService.refreshAuth$.next(false)
65 }
66}
Note: See TracBrowser for help on using the repository browser.