import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; import { RouterModule } from '@angular/router'; import { KeycloakService } from 'keycloak-angular'; @Component({ selector: 'app-navbar', templateUrl: './navbar.component.html', standalone: true, imports: [RouterModule], changeDetection: ChangeDetectionStrategy.OnPush, }) export class NavbarComponent { isMenuOpen = false; private keycloakService: KeycloakService = inject(KeycloakService); isLoggedIn = this.keycloakService.isLoggedIn(); login() { try { const baseUrl = window.location.origin; this.keycloakService.login({ redirectUri: `${baseUrl}/login/success` }); } catch (error) { console.error('Login failed:', error); } } logout() { this.keycloakService.logout(); } toggleMenu() { this.isMenuOpen = !this.isMenuOpen; } }