From 6acdbd3958da13b7a1e4e2fb8cb2bafcdef040e5 Mon Sep 17 00:00:00 2001 From: Oriol Agost Batalla Date: Wed, 25 Oct 2023 19:37:35 +0200 Subject: [PATCH] feat: fix route, redirect to refuge list --- .../app/pages/refuges/refuge-update/refuge-udpate.page.ts | 8 ++++---- app/src/app/services/refuge/refuge.service.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/app/pages/refuges/refuge-update/refuge-udpate.page.ts b/app/src/app/pages/refuges/refuge-update/refuge-udpate.page.ts index a689f0a..0ec77b1 100644 --- a/app/src/app/pages/refuges/refuge-update/refuge-udpate.page.ts +++ b/app/src/app/pages/refuges/refuge-update/refuge-udpate.page.ts @@ -296,8 +296,8 @@ export class RefugeUdpatePage implements OnInit { private handleUpdateRefugeResponse(response: UpdateRefugeResponse) { match(response) - .with({ status: 'updated' }, (response) => { - this.handleCorrectCreateRefugeResponse(response.data); + .with({ status: 'updated' }, () => { + this.handleCorrectCreateRefugeResponse(); }) .with({ status: 'error' }, async (response) => { this.handleError(response.error); @@ -305,9 +305,9 @@ export class RefugeUdpatePage implements OnInit { .exhaustive(); } - private handleCorrectCreateRefugeResponse(refuge: Refuge) { + private handleCorrectCreateRefugeResponse() { this.loadingController.dismiss().then(() => { - this.router.navigate(['refuges', refuge.id]).then(); + this.router.navigate(['refuges']).then(); }); } diff --git a/app/src/app/services/refuge/refuge.service.ts b/app/src/app/services/refuge/refuge.service.ts index 1b89fc3..bae80cb 100644 --- a/app/src/app/services/refuge/refuge.service.ts +++ b/app/src/app/services/refuge/refuge.service.ts @@ -193,7 +193,7 @@ export class RefugeService { refuge: UpdateRefuge, ): Observable { const endpoint = this.updateRefugeEndpoint(refuge.id); - return this.http.post(endpoint, refuge).pipe( + return this.http.put(endpoint, refuge).pipe( map((response: Refuge) => updateRefugeResponseFromResponse(response)), catchError((err: HttpErrorResponse) => of(updateRefugeResponseFromError(err)),