added s authState which helps conditonaly render components based on this state stored user details in localStoarge so that server side end point does not get hit in every page load. add a guard which protects routes and redirects to login if user is not logged in. create a logout route
19 lines
625 B
TypeScript
19 lines
625 B
TypeScript
import { Component, inject } from "@angular/core";
|
|
import { LucideAngularModule, Search, ShoppingCart, User } from "lucide-angular";
|
|
import { RouterLink } from "@angular/router";
|
|
import { AuthService, AuthState } from "../../../features/auth/services/auth-service";
|
|
|
|
@Component({
|
|
selector: "app-header",
|
|
imports: [LucideAngularModule, RouterLink],
|
|
templateUrl: "./header.html",
|
|
styleUrl: "./header.css",
|
|
})
|
|
export class Header {
|
|
readonly UserIcon = User;
|
|
readonly CartIcon = ShoppingCart;
|
|
readonly SearchIcon = Search;
|
|
readonly authService = inject(AuthService);
|
|
protected readonly AuthState = AuthState;
|
|
}
|