appeal update case
This commit is contained in:
+5
-22
@@ -335,14 +335,7 @@ export const createCase = (appealTypeId) => {
|
|||||||
var config = {
|
var config = {
|
||||||
method: "post",
|
method: "post",
|
||||||
url: WEBAPI_URL + "incidents",
|
url: WEBAPI_URL + "incidents",
|
||||||
headers: {
|
azureHeaders,
|
||||||
"OData-MaxVersion": "4.0",
|
|
||||||
"OData-Version": "4.0",
|
|
||||||
"Accept": "application/json",
|
|
||||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"ServiceBusAuthorization": SASToken,
|
|
||||||
},
|
|
||||||
data: data,
|
data: data,
|
||||||
};
|
};
|
||||||
console.log(config);
|
console.log(config);
|
||||||
@@ -356,23 +349,13 @@ export const createCase = (appealTypeId) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateCase = (incidentID, appealTypeId) => {
|
export const updateCase = (incidentId, updateBody, updateFormCollection) => {
|
||||||
appealTypeId = parseInt(appealTypeId);
|
var data = JSON.stringify(updateBody);
|
||||||
var data = JSON.stringify({
|
|
||||||
"pinswg_appealcasetype": appealTypeId,
|
|
||||||
});
|
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
method: "patch",
|
method: "patch",
|
||||||
url: WEBAPI_URL + `incidents(${incidentID})`,
|
url: WEBAPI_URL + updateFormCollection + "(" + incidentId + ")",
|
||||||
headers: {
|
azureHeaders,
|
||||||
"OData-MaxVersion": "4.0",
|
|
||||||
"OData-Version": "4.0",
|
|
||||||
"Accept": "application/json",
|
|
||||||
"Prefer": "return=representation",
|
|
||||||
"Authorization": "Bearer " + accessToken,
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
data: data,
|
data: data,
|
||||||
};
|
};
|
||||||
// console.log(config);
|
// console.log(config);
|
||||||
|
|||||||
@@ -432,14 +432,15 @@ export function NumericField(props) {
|
|||||||
</label>
|
</label>
|
||||||
<Field
|
<Field
|
||||||
name={props.name}
|
name={props.name}
|
||||||
id={"int_" + props.name}
|
id={props.name}
|
||||||
component="input"
|
component="input"
|
||||||
type="text"
|
type="number"
|
||||||
className="govuk-input govuk-input--width-20"
|
className="govuk-input govuk-input--width-20"
|
||||||
spellCheck="false"
|
spellCheck="false"
|
||||||
//aria-describedby="account-number-hint"
|
//aria-describedby="account-number-hint"
|
||||||
pattern="[0-9]*"
|
pattern="[0-9]*"
|
||||||
inputMode="numeric"
|
inputMode="numeric"
|
||||||
|
parse={Number}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -455,14 +456,15 @@ export function DecimalField(props) {
|
|||||||
</label>
|
</label>
|
||||||
<Field
|
<Field
|
||||||
name={props.name}
|
name={props.name}
|
||||||
id={"dec_" + props.name}
|
id={props.name}
|
||||||
component="input"
|
component="input"
|
||||||
type="text"
|
type="number"
|
||||||
className="govuk-input govuk-input--width-10"
|
className="govuk-input govuk-input--width-10"
|
||||||
spellCheck="false"
|
spellCheck="false"
|
||||||
//aria-describedby="account-number-hint"
|
//aria-describedby="account-number-hint"
|
||||||
pattern="[0-9]*"
|
pattern="[0-9]*"
|
||||||
inputMode="numeric"
|
inputMode="numeric"
|
||||||
|
parse={Number}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,26 +8,57 @@ import { reduxForm, formValueSelector } from "redux-form";
|
|||||||
import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
|
import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
|
||||||
import { setCurrentSection } from "../../store/appealType/action";
|
import { setCurrentSection } from "../../store/appealType/action";
|
||||||
import { updateCase } from "../../actions";
|
import { updateCase } from "../../actions";
|
||||||
|
import jsonpath from "jsonpath";
|
||||||
|
|
||||||
|
import data from "../../data/collections.json";
|
||||||
|
|
||||||
let CompleteAppeal = (props) => {
|
let CompleteAppeal = (props) => {
|
||||||
// un comment to update incident with an appealtype id
|
// un comment to update incident with an appealtype id
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// updateCase(
|
// console.log(props.appealType.caseReference.incidentid);
|
||||||
// props.appealType.caseReference.incidentid,
|
// console.log(props.appealType.appealTypeID);
|
||||||
// props.appealType.appealTypeID,
|
// console.log(props.props.form.appealForm.values);
|
||||||
// props.form.appealform.values,
|
|
||||||
// pinswg_appealcasetype@OData.Community.Display.V1.Formatted
|
// console.log(updateBody);
|
||||||
// );
|
// console.log(
|
||||||
console.log(props.appealType.caseReference.incidentid);
|
// getFormCollection(
|
||||||
console.log(props.appealType.appealTypeID);
|
// "pinswg_" +
|
||||||
console.log(props.form);
|
// props.appealType.caseReference[
|
||||||
console.log(
|
// "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
|
||||||
props.appealType.caseReference[
|
// ]
|
||||||
"pinswg_appealcasetype@OData.Community.Display.V1.Formatted"
|
// .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();
|
let { t } = useTranslation();
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -67,8 +98,8 @@ let CompleteAppeal = (props) => {
|
|||||||
setCurrentSection(currentSection + 1);
|
setCurrentSection(currentSection + 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(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));
|
//alert(JSON.stringify(props.props.form.appealForm.values, null, 2));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="govuk-grid-row">
|
<div className="govuk-grid-row">
|
||||||
|
|||||||
Reference in New Issue
Block a user