Skip to content

Commit c68ae64

Browse files
authored
Merge pull request #2957 from abilpraju-aot/FWF-5407
FWF-5407 [BUGFIX] updated call for application count while unpublish…
2 parents ad7b100 + 8cd89ee commit c68ae64

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

forms-flow-web/src/routes/Design/Forms/FormEdit.js

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ import {
5252
saveFormProcessMapperPut,
5353
getProcessDetails,
5454
unPublishForm,
55-
getFormProcesses
55+
getFormProcesses,
56+
getApplicationCount
5657
} from "../../../apiManager/services/processServices";
5758
import _ from "lodash";
5859
import SettingsModal from "../../../components/Modals/SettingsModal.js";
@@ -814,7 +815,15 @@ const handleSaveLayout = () => {
814815
await actionFunction(processListData.id);
815816
if (isPublished) {
816817
await fetchProcessDetails(processListData);
817-
dispatch(getFormProcesses(formId));
818+
// Refresh mapper data and application count after unpublish to ensure UI state is updated
819+
await new Promise((resolve) => {
820+
dispatch(getFormProcesses(formId, (err, data) => {
821+
if (!err && data?.id) {
822+
dispatch(getApplicationCount(data.id));
823+
}
824+
resolve();
825+
}));
826+
});
818827
}
819828
setPromptNewVersion(isPublished);
820829
setIsPublished(!isPublished);
@@ -1077,21 +1086,24 @@ const handleSaveLayout = () => {
10771086
setIsDeletionLoading(true);
10781087
dispatch(deleteForm("form", formId,() => {
10791088
// Callback after form deletion;
1080-
dispatch(push(`${redirectUrl}formflow`));
1089+
if (processListData.id) {
1090+
dispatch(
1091+
unPublishForm(processListData.id, (err) => {
1092+
const message = `${_.capitalize(
1093+
processListData?.formType
1094+
)} deletion ${err ? "unsuccessful" : "successfully"}`;
1095+
toast[err ? "error" : "success"](t(message));
1096+
setIsDeletionLoading(false);
1097+
dispatch(push(`${redirectUrl}formflow`));
1098+
})
1099+
);
1100+
} else {
1101+
setIsDeletionLoading(false);
1102+
dispatch(push(`${redirectUrl}formflow`));
1103+
}
10811104
}));
10821105
}
10831106

1084-
if (processListData.id) {
1085-
dispatch(
1086-
unPublishForm(processListData.id, (err) => {
1087-
const message = `${_.capitalize(
1088-
processListData?.formType
1089-
)} deletion ${err ? "unsuccessful" : "successfully"}`;
1090-
toast[err ? "error" : "success"](t(message));
1091-
})
1092-
);
1093-
}
1094-
10951107
dispatch(
10961108
setFormDeleteStatus({ modalOpen: false, formId: "", formName: "" })
10971109
);

0 commit comments

Comments
 (0)