diff --git a/actions/index.js b/actions/index.js
index 2970eb72..c43c6f44 100644
--- a/actions/index.js
+++ b/actions/index.js
@@ -335,14 +335,7 @@ export const createCase = (appealTypeId) => {
var config = {
method: "post",
url: WEBAPI_URL + "incidents",
- headers: {
- "OData-MaxVersion": "4.0",
- "OData-Version": "4.0",
- "Accept": "application/json",
- "Prefer": 'odata.include-annotations="*",return=representation',
- "Content-Type": "application/json",
- "ServiceBusAuthorization": SASToken,
- },
+ azureHeaders,
data: data,
};
console.log(config);
@@ -356,23 +349,13 @@ export const createCase = (appealTypeId) => {
});
};
-export const updateCase = (incidentID, appealTypeId) => {
- appealTypeId = parseInt(appealTypeId);
- var data = JSON.stringify({
- "pinswg_appealcasetype": appealTypeId,
- });
+export const updateCase = (incidentId, updateBody, updateFormCollection) => {
+ var data = JSON.stringify(updateBody);
var config = {
method: "patch",
- url: WEBAPI_URL + `incidents(${incidentID})`,
- headers: {
- "OData-MaxVersion": "4.0",
- "OData-Version": "4.0",
- "Accept": "application/json",
- "Prefer": "return=representation",
- "Authorization": "Bearer " + accessToken,
- "Content-Type": "application/json",
- },
+ url: WEBAPI_URL + updateFormCollection + "(" + incidentId + ")",
+ azureHeaders,
data: data,
};
// console.log(config);
diff --git a/components/elements/index.js b/components/elements/index.js
index fc7f20b9..e3824ff1 100644
--- a/components/elements/index.js
+++ b/components/elements/index.js
@@ -432,14 +432,15 @@ export function NumericField(props) {
);
@@ -455,14 +456,15 @@ export function DecimalField(props) {
);
diff --git a/components/newappeal/complete.js b/components/newappeal/complete.js
index 77ace2f4..2fef3643 100644
--- a/components/newappeal/complete.js
+++ b/components/newappeal/complete.js
@@ -8,26 +8,57 @@ import { reduxForm, formValueSelector } from "redux-form";
import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
import { setCurrentSection } from "../../store/appealType/action";
import { updateCase } from "../../actions";
+import jsonpath from "jsonpath";
+
+import data from "../../data/collections.json";
let CompleteAppeal = (props) => {
// un comment to update incident with an appealtype id
useEffect(() => {
- // updateCase(
- // props.appealType.caseReference.incidentid,
- // props.appealType.appealTypeID,
- // props.form.appealform.values,
- // pinswg_appealcasetype@OData.Community.Display.V1.Formatted
- // );
- console.log(props.appealType.caseReference.incidentid);
- console.log(props.appealType.appealTypeID);
- console.log(props.form);
- console.log(
- props.appealType.caseReference[
- "pinswg_appealcasetype@OData.Community.Display.V1.Formatted"
- ]
+ // console.log(props.appealType.caseReference.incidentid);
+ // console.log(props.appealType.appealTypeID);
+ // console.log(props.props.form.appealForm.values);
+
+ // console.log(updateBody);
+ // console.log(
+ // getFormCollection(
+ // "pinswg_" +
+ // props.appealType.caseReference[
+ // "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
+ // ]
+ // .replace(/[\s\-\+\(\)\,\&\.]/g, "")
+ // .toLowerCase()
+ // )
+ // );
+
+ let incidentId = props.appealType.caseReference.incidentid;
+ let updateBody = props.props.form.appealForm.values;
+ updateBody = JSON.stringify(updateBody);
+
+ updateBody = updateBody.replace(/:"Yes"/gm, `:true`);
+ updateBody = updateBody.replace(/:"No"/gm, `:false`);
+ updateBody = JSON.parse(updateBody);
+ let updateFormCollection = getFormCollection(
+ "pinswg_" +
+ props.appealType.caseReference[
+ "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
+ ]
+ .replace(/[\s\-\+\(\)\,\&\.]/g, "")
+ .toLowerCase()
);
+
+ updateCase(incidentId, updateBody, updateFormCollection);
}, []);
+ const getFormCollection = (formtype) => {
+ const collectionName = jsonpath.query(
+ data,
+ "$..[?(@.LogicalName=='" + formtype + "')].LogicalCollectionName"
+ );
+ //console.log(collectionName[0]);
+ return collectionName[0];
+ };
+
let { t } = useTranslation();
const router = useRouter();
@@ -67,8 +98,8 @@ let CompleteAppeal = (props) => {
setCurrentSection(currentSection + 1);
};
- console.log(JSON.stringify(props.props.form.appealForm.values, null, 2));
- alert(JSON.stringify(props.props.form.appealForm.values, null, 2));
+ // console.log(JSON.stringify(props.props.form.appealForm.values, null, 2));
+ //alert(JSON.stringify(props.props.form.appealForm.values, null, 2));
return (