38 lines
1014 B
TypeScript
38 lines
1014 B
TypeScript
import { Component, inject } from '@angular/core';
|
|
import { CommonModule } from '@angular/common';
|
|
import { Router } from '@angular/router';
|
|
import { Store } from '@ngrx/store';
|
|
import { NgIcon, provideIcons } from '@ng-icons/core';
|
|
import {
|
|
lucideUser,
|
|
lucideLogIn,
|
|
lucideUserPlus
|
|
} from '@ng-icons/lucide';
|
|
import { selectCurrentUser } from '../../../store/users/users.selectors';
|
|
|
|
@Component({
|
|
selector: 'app-user-bar',
|
|
standalone: true,
|
|
imports: [CommonModule, NgIcon],
|
|
viewProviders: [
|
|
provideIcons({ lucideUser,
|
|
lucideLogIn,
|
|
lucideUserPlus })
|
|
],
|
|
templateUrl: './user-bar.component.html'
|
|
})
|
|
/**
|
|
* Compact user status bar showing the current user with login/register navigation links.
|
|
*/
|
|
export class UserBarComponent {
|
|
store = inject(Store);
|
|
user = this.store.selectSignal(selectCurrentUser);
|
|
|
|
private router = inject(Router);
|
|
|
|
/** Navigate to the specified authentication page. */
|
|
goto(path: 'login' | 'register') {
|
|
this.router.navigate([`/${path}`]);
|
|
}
|
|
}
|