Skip to content

Commit

Permalink
fix: double header display in checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
SGrueber committed Oct 26, 2024
1 parent e31a906 commit 703f9dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/app/core/guards/no-server-side-rendering.guard.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { inject } from '@angular/core';
import { Router } from '@angular/router';
import { ActivatedRouteSnapshot, Router } from '@angular/router';

/**
* guards a route against server side rendering (e.g. if the logic requires information only available in browser rendering)
*/
export function noServerSideRenderingGuard() {
export function noServerSideRenderingGuard(route: ActivatedRouteSnapshot) {
const router = inject(Router);

// prevent any handling in the server side rendering (SSR) and instead show loading
if (SSR) {
return router.parseUrl('/loading');
return router.parseUrl(route.data.headerType === 'checkout' ? '/loading/checkout' : '/loading');
}

// if not in SSR just return true and continue
Expand Down
7 changes: 7 additions & 0 deletions src/app/pages/loading/loading-page.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ const loadingPageRoutes: Routes = [
headerType: 'simple',
},
},
{
path: 'checkout',
component: LoadingPageComponent,
data: {
headerType: 'checkout',
},
},
];

@NgModule({
Expand Down

0 comments on commit 703f9dc

Please sign in to comment.