]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+page-not-found/page-not-found.component.ts
fix localization on page not found
[github/Chocobozzz/PeerTube.git] / client / src / app / +page-not-found / page-not-found.component.ts
index 81830d4152644fb0c4060fb424f0fef3bb6ff2a6..94b4c8d27f5d4763cba5c2efb28323ad11ea4ff7 100644 (file)
@@ -1,5 +1,6 @@
 import { Component, OnInit } from '@angular/core'
 import { Title } from '@angular/platform-browser'
+import { Router } from '@angular/router'
 import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
 
 @Component({
@@ -9,10 +10,16 @@ import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
 })
 export class PageNotFoundComponent implements OnInit {
   status = HttpStatusCode.NOT_FOUND_404
+  type: string
 
   public constructor (
-    private titleService: Title
-  ) {}
+    private titleService: Title,
+    private router: Router
+  ) {
+    const state = this.router.getCurrentNavigation()?.extras.state
+    this.type = state?.type || this.type
+    this.status = state?.obj.status || this.status
+  }
 
   ngOnInit () {
     if (this.pathname.includes('teapot')) {
@@ -29,6 +36,8 @@ export class PageNotFoundComponent implements OnInit {
     switch (this.status) {
       case HttpStatusCode.I_AM_A_TEAPOT_418:
         return 'happy'
+      case HttpStatusCode.FORBIDDEN_403:
+        return 'arguing'
       case HttpStatusCode.NOT_FOUND_404:
       default:
         return 'defeated'