From 5c5a482541e11a80d0d705cb2ecbfbc1a712df08 Mon Sep 17 00:00:00 2001 From: Bonymol-aot Date: Wed, 16 Oct 2024 23:50:40 -0700 Subject: [PATCH] [FWF-3757: Added form title change after update, fixed pathname and anonymous url issues] --- .../src/components/Form/Item/Edit.js | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/forms-flow-web/src/components/Form/Item/Edit.js b/forms-flow-web/src/components/Form/Item/Edit.js index 60463091e8..0ad475d7f0 100644 --- a/forms-flow-web/src/components/Form/Item/Edit.js +++ b/forms-flow-web/src/components/Form/Item/Edit.js @@ -351,8 +351,17 @@ const Edit = React.memo(() => { roles: rolesState.create.selectedOption === "specifiedRoles" ? rolesState.create.selectedRoles : [], } }; - dispatch(saveFormProcessMapperPut({ mapper, authorizations })); - handleCloseModal(); + + const savePromise = dispatch(saveFormProcessMapperPut({ mapper, authorizations })); + const updatePromise = updateFormPath(); + + Promise.all([savePromise, updatePromise]) + .then(() => { + handleCloseModal(); + }) + .catch(error => { + console.error("Error saving form process:", error); + }); }; @@ -388,6 +397,22 @@ const Edit = React.memo(() => { }); }; + + const updateFormPath = () => { + const newFormData = manipulatingFormData( + _.cloneDeep(form), + MULTITENANCY_ENABLED, + tenantKey, + formAccess, + submissionAccess + ); + newFormData.path = newPath; + newFormData.title = formDetails.name; + formUpdate(newFormData._id, newFormData); + + + }; + const backToForm = () => { dispatch(push(`${redirectUrl}form/`)); };