summaryrefslogtreecommitdiff
path: root/src/clients
diff options
context:
space:
mode:
Diffstat (limited to 'src/clients')
-rw-r--r--src/clients/actions.ts9
1 files changed, 4 insertions, 5 deletions
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`);
}