Skip to content

Commit

Permalink
Merge pull request #1560 from Bonymol-aot/invalidURL_fix
Browse files Browse the repository at this point in the history
Updated page for incorrect URLs
  • Loading branch information
abhilash-aot authored Aug 23, 2023
2 parents 039a05e + 01d7eee commit e5567e7
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 35 deletions.
12 changes: 10 additions & 2 deletions forms-flow-web/src/components/Form/Item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import Submission from "./Submission/index";
import { checkIsObjectId } from "../../../apiManager/services/formatterService";
import { fetchFormByAlias } from "../../../apiManager/services/bpmFormServices";
import {
setFormFailureErrorData,
setFormRequestData,
setFormSuccessData,
resetFormData,
Expand Down Expand Up @@ -82,7 +81,16 @@ const Item = React.memo(() => {

} else {
dispatch(setFormAuthVerifyLoading(false));
dispatch(setFormFailureErrorData("form", err));
const { response } = err;
dispatch(
setApiCallError({
message:
response?.data?.message ||
response?.statusText ||
err.message,
status: response?.status ,
})
);
}
})
);
Expand Down
93 changes: 60 additions & 33 deletions forms-flow-web/src/components/Form/Stepper.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
saveFormProcessMapperPost,
saveFormProcessMapperPut,
} from "../../apiManager/services/processServices";
import { selectRoot, selectError, Formio, getForm} from "react-formio";
import { selectRoot, selectError, Formio, getForm } from "react-formio";
import { MULTITENANCY_ENABLED } from "../../constants/constants";
import { push } from "connected-react-router";
import WorkFlow from "./Steps/WorkFlow";
Expand Down Expand Up @@ -63,12 +63,13 @@ class StepperPage extends PureComponent {
disablePreview: false,
tenantKey: props.tenants?.tenantId,
redirectUrl: null,
checkPermissionLoading:false,
checkPermissionLoading: false,
};

this.setPreviewMode = this.setPreviewMode.bind(this);
this.handleNext = this.handleNext.bind(this);
this.handleCheckPermissionLoading = this.handleCheckPermissionLoading.bind(this);
this.handleCheckPermissionLoading =
this.handleCheckPermissionLoading.bind(this);
// for edit
this.setEditMode = this.setEditMode.bind(this);
this.handleBack = this.handleBack.bind(this);
Expand Down Expand Up @@ -159,7 +160,6 @@ class StepperPage extends PureComponent {
return { ...stateData };
}


setActiveStep(val) {
this.setState({ activeStep: val });
}
Expand All @@ -182,7 +182,7 @@ class StepperPage extends PureComponent {
: "/",
});
}

setProcessData = (data) => {
this.setState((prevState) => ({
processData: { ...prevState.processData, ...data },
Expand Down Expand Up @@ -215,8 +215,10 @@ class StepperPage extends PureComponent {
this.setActiveStep(this.state.activeStep - 1);
}

handleCheckPermissionLoading(){
this.setState({checkPermissionLoading:!this.state?.checkPermissionLoading});
handleCheckPermissionLoading() {
this.setState({
checkPermissionLoading: !this.state?.checkPermissionLoading,
});
}

submitData = () => {
Expand Down Expand Up @@ -250,7 +252,7 @@ class StepperPage extends PureComponent {
: [],
anonymous: formProcessList.anonymous ? true : false,
parentFormId: formProcessList?.parentFormId,
formType: formProcessList.formType
formType: formProcessList.formType,
};

if (workflow) {
Expand All @@ -270,7 +272,7 @@ class StepperPage extends PureComponent {
}

data.workflowChanged = data?.processKey !== formPreviousData.processKey;
data.statusChanged = processData?.status !== formPreviousData.status;
data.statusChanged = processData?.status !== formPreviousData.status;

if (isNewVersionNeeded()) {
// POST request for creating new mapper version of the current form.
Expand Down Expand Up @@ -345,22 +347,22 @@ class StepperPage extends PureComponent {
render() {
// const { process } = this.props;
const steps = this.getSteps();
const { t,formAuthVerifyLoading, apiCallError,match} = this.props;
const { t, formAuthVerifyLoading, apiCallError, match } = this.props;
const handleReset = () => {
this.setActiveStep(0);
};



if(formAuthVerifyLoading && match?.params.formId !== FORM_CREATE_ROUTE){
return <Loading/>;
if (formAuthVerifyLoading && match?.params.formId !== FORM_CREATE_ROUTE) {
return <Loading />;
}

if(apiCallError){
return <NotFound
errorMessage={apiCallError.message}
errorCode={apiCallError.status}
/>;
if (apiCallError) {
return (
<NotFound
errorMessage={apiCallError.message}
errorCode={apiCallError.status}
/>
);
}

return (
Expand Down Expand Up @@ -475,27 +477,52 @@ const mapDispatchToProps = (dispatch) => {
dispatch(setApiCallError(null));
dispatch(resetFormData("form", id));
dispatch(setFormAuthVerifyLoading(true));
dispatch(getForm("form",id,(err,res)=>{
fetchFormAuthorizationDetials(
res?.parentFormId || res?._id).then(response=>{
dispatch(setFormAuthorizationDetails(response.data));
}).catch((err)=>{
const {response} = err;
dispatch(setApiCallError({message:response?.data?.message ||
response.statusText,status:response.status}));
}).finally(()=>{
dispatch(
getForm("form", id, (err, res) => {
if (err) {
const { response } = err;
dispatch(
setApiCallError({
message:
response?.data?.message ||
"Bad Request" ||
response?.statusText ||
err.message,
status: response?.status || "400",
})
);
dispatch(setFormAuthVerifyLoading(false));
});
}));

} else {
fetchFormAuthorizationDetials(res?.parentFormId || res._id)
.then((response) => {
dispatch(setFormAuthorizationDetails(response.data));
})
.catch((err) => {
const { response } = err;
dispatch(
setApiCallError({
message:
response?.data?.message ||
response?.statusText ||
err.message,
status: response?.status || "400",
})
);
})
.finally(() => {
dispatch(setFormAuthVerifyLoading(false));
});
}
})
);
},
getFormProcessesDetails: (formId) => {
dispatch(
// eslint-disable-next-line no-unused-vars
getFormProcesses(formId, (err, data) => {
if (!err) {
dispatch(getApplicationCount(data.id));
}else{
} else {
console.error(err);
}
})
Expand Down

0 comments on commit e5567e7

Please sign in to comment.