diff --git a/src/app/shared/components/header/header.component.ts b/src/app/shared/components/header/header.component.ts index 82b7fbb..5b9aa83 100644 --- a/src/app/shared/components/header/header.component.ts +++ b/src/app/shared/components/header/header.component.ts @@ -18,16 +18,29 @@ export class HeaderComponent { constructor(public firebaseService: FirebaseService) {} - toggleNavbar() { + /** + * Toggles the visibility of the navbar. + * @returns {void} + */ + toggleNavbar(): void { this.navbarVisible = !this.navbarVisible; } - toggleLanguage() { + /** + * Toggles the visibility of the language selection navbar. + * @returns {void} + */ + toggleLanguage(): void { this.navbarLanguageVisible = !this.navbarLanguageVisible; } @HostListener('document:click', ['$event']) - checkOpenNavbar(event: MouseEvent) { + /** + * Closes the navbar if the user clicks outside of it + * @param event a MouseEvent + * @returns {void} + */ + checkOpenNavbar(event: MouseEvent): void { const targetElement = event.target as HTMLElement; if ( !targetElement.closest('app-navbar') && diff --git a/src/app/shared/components/header/navbar/navbar.component.ts b/src/app/shared/components/header/navbar/navbar.component.ts index a21bd19..905a120 100644 --- a/src/app/shared/components/header/navbar/navbar.component.ts +++ b/src/app/shared/components/header/navbar/navbar.component.ts @@ -1,6 +1,5 @@ import { Component, Input } from '@angular/core'; import { Router, RouterModule } from '@angular/router'; -import { HeaderComponent } from '../header.component'; import { LanguageService } from '../../../../services/language.service'; import { CommonModule } from '@angular/common'; import { TranslateModule } from '@ngx-translate/core'; @@ -10,7 +9,7 @@ import { FirebaseService } from '../../../../services/firebase.service'; @Component({ selector: 'app-navbar', standalone: true, - imports: [RouterModule, HeaderComponent, CommonModule, TranslateModule], + imports: [RouterModule, CommonModule, TranslateModule], templateUrl: './navbar.component.html', styleUrl: './navbar.component.scss', }) @@ -27,10 +26,24 @@ export class NavbarComponent { private firebaseService: FirebaseService ) {} + /** + * OnInit lifecycle hook. + * + * Sets the currentRoute property to the current route's url. + */ ngOnInit() { this.currentRoute = this.router.url; } + /** + * Logs out the current user and navigates to the login page. + * + * The logout method of the LoginService is called with the current user ID as + * its argument. This will remove the user ID from the local storage and + * perform any other necessary cleanup operations. + * + * The user is then navigated to the login page. + */ logout() { this.loginService.logout(this.firebaseService.getCurrentUserId()); }