Skip to content

Commit

Permalink
feat: display maintenance page only if the error still exists otherwi…
Browse files Browse the repository at this point in the history
…se route to the home page
  • Loading branch information
SGrueber committed Sep 8, 2022
1 parent ed7694e commit 11cf6d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/app/core/guards/error-status.guard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Injectable } from '@angular/core';
import { CanActivate, Router } from '@angular/router';
import { map } from 'rxjs';

import { AppFacade } from 'ish-core/facades/app.facade';

@Injectable({ providedIn: 'root' })
export class ErrorStatusGuard implements CanActivate {
constructor(private appFacade: AppFacade, private router: Router) {}
canActivate() {
return this.appFacade.generalError$.pipe(map(error => (!error ? this.router.parseUrl('/home') : true)));
}
}
2 changes: 2 additions & 0 deletions src/app/pages/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { AuthGuard } from 'ish-core/guards/auth.guard';
import { ErrorStatusGuard } from 'ish-core/guards/error-status.guard';
import { IdentityProviderInviteGuard } from 'ish-core/guards/identity-provider-invite.guard';
import { IdentityProviderLoginGuard } from 'ish-core/guards/identity-provider-login.guard';
import { IdentityProviderLogoutGuard } from 'ish-core/guards/identity-provider-logout.guard';
Expand Down Expand Up @@ -33,6 +34,7 @@ const routes: Routes = [
{
path: 'maintenance',
loadChildren: () => import('./maintenance/maintenance-page.module').then(m => m.MaintenancePageModule),
canActivate: [ErrorStatusGuard],
data: {
meta: {
title: 'seo.title.maintenance',
Expand Down

0 comments on commit 11cf6d2

Please sign in to comment.