From 2cc3bd2a5ab71ced121ea6e8fef3be5db2b98e4f Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Mon, 15 May 2023 21:06:06 -0600 Subject: Resuelto bug de renderizado de errores --- src/clients/actions.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/clients') diff --git a/src/clients/actions.ts b/src/clients/actions.ts index ea3c332..bfddf54 100644 --- a/src/clients/actions.ts +++ b/src/clients/actions.ts @@ -1,6 +1,6 @@ import { redirect } from "react-router-dom"; import { ApiClient } from "./api_client"; -import { deleteEmptyFields } from "../lib/form_utils"; +import { clearSessionStorage, deleteEmptyFields, setFormErrorsInSessionStorage } from "../lib/form_utils"; import Token from "../lib/token"; export async function editAccount({ request }) { @@ -19,12 +19,13 @@ export async function editAccount({ request }) { } export async function editAddress({ params, request }) { - + clearSessionStorage(); const client = new ApiClient(); let form_data = await request.formData(); form_data = deleteEmptyFields(form_data); try { + const response = await client.put(`/account/addresses/${params.addressId}`, form_data); if(response.status == 401 || response.status == 404) @@ -38,9 +39,7 @@ export async function editAddress({ params, request }) { return redirect("/products") } else { - for(const [key, value] of Object.entries(error.response.data.errors)) { - sessionStorage.setItem(key, value); - } + setFormErrorsInSessionStorage(error.response.data.errors); return redirect(`/account/addresses/${params.addressId}/edit`); } -- cgit v1.2.3