update new form recipe detail

This commit is contained in:
Kenta420 2023-10-05 16:04:08 +07:00
parent df20d25a35
commit e95078307b
8 changed files with 500 additions and 10 deletions

View file

@ -5,12 +5,14 @@ import {
HttpEvent,
HttpInterceptor,
HttpErrorResponse,
HttpStatusCode,
} from '@angular/common/http';
import { Observable, catchError, retry, throwError } from 'rxjs';
import { Observable, catchError, throwError } from 'rxjs';
import { Router } from '@angular/router';
@Injectable({ providedIn: 'root' })
export class ErrorInterceptor implements HttpInterceptor {
constructor() {}
constructor(private router: Router) {}
intercept(
request: HttpRequest<unknown>,
@ -19,6 +21,13 @@ export class ErrorInterceptor implements HttpInterceptor {
return next.handle(request).pipe(
catchError((error) => {
if (error instanceof HttpErrorResponse) {
if (error.status == HttpStatusCode.Unauthorized) {
this.router.navigate(['/login'], {
queryParams: {
redirectUrl: request.url,
},
});
}
}
return throwError(() => error);
})

View file

@ -3,7 +3,6 @@ import { HttpClient } from '@angular/common/http';
import {
BehaviorSubject,
Observable,
concat,
distinctUntilChanged,
map,
tap,