2023-08-18 18:33:09 +02:00
|
|
|
import { Component, OnInit, Output, EventEmitter } from '@angular/core';
|
2023-08-17 18:51:39 +02:00
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
import { ApiService } from '../../services/api.service';
|
|
|
|
import { MenuGroup } from '../../interfaces/services.interface';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-menu',
|
|
|
|
templateUrl: './menu.component.html',
|
|
|
|
styleUrls: ['./menu.component.scss']
|
|
|
|
})
|
|
|
|
|
|
|
|
export class MenuComponent implements OnInit {
|
2023-08-18 17:56:07 +02:00
|
|
|
navOpen: boolean = false;
|
2023-08-17 18:51:39 +02:00
|
|
|
userMenuGroups$: Observable<MenuGroup[]> | undefined;
|
2023-08-18 18:04:40 +02:00
|
|
|
userAuth: any | undefined;
|
2023-08-18 18:33:09 +02:00
|
|
|
@Output() loggedOut = new EventEmitter<boolean>();
|
2023-08-17 18:51:39 +02:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
private apiService: ApiService
|
|
|
|
) {}
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
2023-08-18 18:04:40 +02:00
|
|
|
this.userAuth = JSON.parse(localStorage.getItem('auth') || '') ?? null;
|
2023-08-17 18:51:39 +02:00
|
|
|
this.userMenuGroups$ = this.apiService.getUserMenuGroups$();
|
|
|
|
}
|
2023-08-17 22:13:06 +02:00
|
|
|
|
|
|
|
logout(): void {
|
2023-08-18 17:56:07 +02:00
|
|
|
this.apiService.logout$().subscribe();
|
2023-08-18 18:33:09 +02:00
|
|
|
this.loggedOut.emit(true);
|
2023-08-18 17:56:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hambugerClick() {
|
|
|
|
this.navOpen = !this.navOpen;
|
2023-08-17 22:13:06 +02:00
|
|
|
}
|
2023-08-17 18:51:39 +02:00
|
|
|
}
|