diff --git a/src/app/pages/static-page/static-page.component.html b/src/app/pages/static-page/static-page.component.html index 33d3ac7..95d0bf0 100644 --- a/src/app/pages/static-page/static-page.component.html +++ b/src/app/pages/static-page/static-page.component.html @@ -6,6 +6,14 @@ + } @else if (error()) { +
+ +
+ {{ 'staticPages.backHome' | translate }} +
+
+
} @else if (notFound()) {
diff --git a/src/app/pages/static-page/static-page.component.ts b/src/app/pages/static-page/static-page.component.ts index 247855b..47698d2 100644 --- a/src/app/pages/static-page/static-page.component.ts +++ b/src/app/pages/static-page/static-page.component.ts @@ -29,6 +29,7 @@ export class StaticPageComponent { readonly loading = signal(true); readonly notFound = signal(false); + readonly error = signal(false); readonly title = signal(''); readonly homeRoute = signal(''); readonly dir = signal<'ltr' | 'rtl'>('ltr'); @@ -76,21 +77,32 @@ export class StaticPageComponent { private loadByKey(key: string): void { this.loading.set(true); this.notFound.set(false); + this.error.set(false); - this.staticPageResolver.resolveByKey(key, this.languageService.currentLanguage()).subscribe(page => { - this.applyPage(page?.title ?? '', page?.html ?? '', !page); + this.staticPageResolver.resolveByKey(key, this.languageService.currentLanguage()).subscribe({ + next: page => this.applyPage(page?.title ?? '', page?.html ?? '', !page), + error: () => this.applyError() }); } private loadByPath(path: string): void { this.loading.set(true); this.notFound.set(false); + this.error.set(false); - this.staticPageResolver.resolveByRoute(path, this.languageService.currentLanguage()).subscribe(page => { - this.applyPage(page?.title ?? '', page?.html ?? '', !page); + this.staticPageResolver.resolveByRoute(path, this.languageService.currentLanguage()).subscribe({ + next: page => this.applyPage(page?.title ?? '', page?.html ?? '', !page), + error: () => this.applyError() }); } + private applyError(): void { + this.title.set(''); + this.safeHtml.set(this.sanitizer.bypassSecurityTrustHtml('')); + this.error.set(true); + this.loading.set(false); + } + private applyPage(title: string, html: string, notFound: boolean): void { if (notFound) { this.title.set('');