appeal update case
This commit is contained in:
+5
-22
@@ -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);
|
||||
|
||||
@@ -432,14 +432,15 @@ export function NumericField(props) {
|
||||
</label>
|
||||
<Field
|
||||
name={props.name}
|
||||
id={"int_" + props.name}
|
||||
id={props.name}
|
||||
component="input"
|
||||
type="text"
|
||||
type="number"
|
||||
className="govuk-input govuk-input--width-20"
|
||||
spellCheck="false"
|
||||
//aria-describedby="account-number-hint"
|
||||
pattern="[0-9]*"
|
||||
inputMode="numeric"
|
||||
parse={Number}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
@@ -455,14 +456,15 @@ export function DecimalField(props) {
|
||||
</label>
|
||||
<Field
|
||||
name={props.name}
|
||||
id={"dec_" + props.name}
|
||||
id={props.name}
|
||||
component="input"
|
||||
type="text"
|
||||
type="number"
|
||||
className="govuk-input govuk-input--width-10"
|
||||
spellCheck="false"
|
||||
//aria-describedby="account-number-hint"
|
||||
pattern="[0-9]*"
|
||||
inputMode="numeric"
|
||||
parse={Number}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -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 (
|
||||
<div className="govuk-grid-row">
|
||||
|
||||
Reference in New Issue
Block a user