Skip to content

Commit

Permalink
fixed custom submission data populate issue (#1580)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuhaib-aot authored Aug 22, 2023
1 parent 0a75ed1 commit 029acd9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,15 @@ const Edit = React.memo((props) => {
formId,
onFormSubmit,
]);
let updatedSubmission = useMemo(()=>{
const updatedSubmission = useMemo(()=>{
if (CUSTOM_SUBMISSION_URL && CUSTOM_SUBMISSION_ENABLE) {
return customSubmission;
} else {
return submission;
}
},[customSubmission,submission]);
if (isFormActive || (isSubActive && !isFormSubmissionLoading)) {

if (isFormActive || (isSubActive && !isFormSubmissionLoading) || !updatedSubmission?.data) {
return <Loading />;
}

Expand Down
17 changes: 9 additions & 8 deletions forms-flow-web/src/components/Form/Item/Submission/Item/View.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useMemo } from "react";
import { connect, useSelector } from "react-redux";
import {
selectRoot,
Expand Down Expand Up @@ -39,14 +39,15 @@ const View = React.memo((props) => {
(state) => state.customSubmission?.submission || {}
);

let updatedSubmission;
if (CUSTOM_SUBMISSION_URL && CUSTOM_SUBMISSION_ENABLE) {
updatedSubmission = customSubmission;
} else {
updatedSubmission = submission;
}
const updatedSubmission = useMemo(()=>{
if (CUSTOM_SUBMISSION_URL && CUSTOM_SUBMISSION_ENABLE) {
return customSubmission;
} else {
return submission;
}
},[customSubmission,submission]);

if (isFormActive || (isSubActive && !isFormSubmissionLoading)) {
if (isFormActive || (isSubActive && !isFormSubmissionLoading) || !updatedSubmission?.data) {
return <Loading />;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import History from "../../Application/ApplicationHistory";
import FormEdit from "../../Form/Item/Submission/Item/Edit";
import FormView from "../../Form/Item/Submission/Item/View";
import LoadingOverlay from "react-loading-overlay";
import { getForm, getSubmission, Formio } from "react-formio";
import { getForm, getSubmission, Formio, resetSubmission } from "react-formio";
import { CUSTOM_EVENT_TYPE } from "../constants/customEventTypes";
import { getTaskSubmitFormReq } from "../../../apiManager/services/bpmServices";
import { useParams } from "react-router-dom";
Expand All @@ -42,6 +42,7 @@ import {
import { getCustomSubmission } from "../../../apiManager/services/FormServices";
import { getFormioRoleIds } from "../../../apiManager/services/userservices";
import { bpmActionError } from "../../../actions/bpmTaskActions";
import { setCustomSubmission } from "../../../actions/checkListActions";
const ServiceFlowTaskDetails = React.memo(() => {
const { t } = useTranslation();
const { taskId } = useParams();
Expand Down Expand Up @@ -125,8 +126,10 @@ const ServiceFlowTaskDetails = React.memo(() => {
getForm("form", formId, (err) => {
if (!err) {
if (CUSTOM_SUBMISSION_URL && CUSTOM_SUBMISSION_ENABLE) {
dispatch(setCustomSubmission({}));
dispatch(getCustomSubmission(submissionId, formId));
} else {
dispatch(resetSubmission("submission"));
dispatch(getSubmission("submission", submissionId, formId));
}
dispatch(setFormSubmissionLoading(false));
Expand Down

0 comments on commit 029acd9

Please sign in to comment.