Skip to content

Commit

Permalink
Merge pull request #75 from BinaryStudioAcademy/bugfix/13-header-on-n…
Browse files Browse the repository at this point in the history
…otfound

hidden header when open not-found-page
  • Loading branch information
tatianahutii committed Aug 31, 2023
2 parents 9c58b5b + 6462520 commit d6db3c1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion frontend/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<app-loading-spinner></app-loading-spinner>
<app-header *ngIf="!isAuthPage"></app-header>
<app-header *ngIf="!isAuthPage && isRouteNotFound"></app-header>
<router-outlet></router-outlet>
19 changes: 18 additions & 1 deletion frontend/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { Component } from '@angular/core';
import { NavigationCancel, NavigationEnd, NavigationError, NavigationStart, Router } from '@angular/router';
import {
NavigationCancel,
NavigationEnd,
NavigationError,
NavigationStart,
Router,
RoutesRecognized,
} from '@angular/router';
import { SpinnerService } from '@core/services/spinner.service';

@Component({
Expand All @@ -9,6 +16,8 @@ import { SpinnerService } from '@core/services/spinner.service';
export class AppComponent {
isAuthPage: boolean;

isRouteNotFound: boolean;

constructor(private router: Router, private spinner: SpinnerService) {
this.listenRouter();
}
Expand All @@ -25,6 +34,14 @@ export class AppComponent {
) {
this.spinner.hide();
}
if (event instanceof RoutesRecognized) {
const route = event.state.root.firstChild;

if (route) {
this.isRouteNotFound = route.routeConfig === null;
}
}

if (event instanceof NavigationStart) {
this.isAuthPage = event.url.startsWith('/auth') || event.url === '/';
}
Expand Down

0 comments on commit d6db3c1

Please sign in to comment.