Skip to content

Commit

Permalink
adding login status on the navbar of the landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
oussamaB14 committed May 2, 2024
1 parent b086f72 commit 76d950f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
22 changes: 15 additions & 7 deletions front/src/app/shared/components/navbar/navbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,27 @@
<div class="navbar-nav ms-auto">
<!-- Conditionally display avatar -->
<ng-container *ngIf="isLoggedIn(); else loginButtons">
<img
class="rounded-circle me-3"
width="30px"
src="../../../../assets/images/alex.jpg"
/>
<a [routerLink]="['/user/dashboard']"
><img
class="rounded-circle me-3"
width="30px"
src="../../../../assets/images/alex.jpg"
/></a>
</ng-container>
<!-- Hide sign-up and log-in buttons when user is logged in -->
<ng-template #loginButtons>
<li class="nav-item me-2 d-none d-sm-block">
<a [routerLink]="['/register']" class="btn btn-sm btn-light mb-0"><i class="bi bi-person-circle me-1"></i>Sign up</a>
<a [routerLink]="['/register']" class="btn btn-sm btn-light mb-0"
><i class="bi bi-person-circle me-1"></i>Sign up</a
>
</li>
<li class="nav-item d-none d-sm-block">
<button class="btn btn-sm btn-primary mb-0" [routerLink]="['/login']">Log in!</button>
<button
class="btn btn-sm btn-primary mb-0"
[routerLink]="['/login']"
>
Log in!
</button>
</li>
</ng-template>
</div>
Expand Down
6 changes: 4 additions & 2 deletions front/src/app/shared/components/navbar/navbar.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, ElementRef, ViewChild } from '@angular/core';
import { AuthService } from '../../../modules/auth/services/auth.service';

@Component({
selector: 'app-navbar',
Expand All @@ -10,7 +11,8 @@ export class NavbarComponent {

lastScrollPosition: number;

constructor() {}
constructor(private authService: AuthService) {}


ngAfterViewInit() {
window.addEventListener('scroll', () => {
Expand All @@ -31,6 +33,6 @@ export class NavbarComponent {
});
}
isLoggedIn(): boolean {
return false;
return this.authService.isLoggedIn();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<div class="side-bar">
<div class="logo">
<img src="assets/images/logo-white.png" alt="logo" width="38" height="38" />
<a [routerLink]="['/']"
><img
src="assets/images/logo-white.png"
alt="logo"
width="38"
height="38"
/></a>
</div>
<div class="menu">
<a href="setting" class="rt-menu">
Expand Down

0 comments on commit 76d950f

Please sign in to comment.