appeal update case

This commit is contained in:
robert.bond@test.gov.wales
2021-09-14 12:23:43 +01:00
parent 1208848d82
commit b7815c112e
3 changed files with 57 additions and 41 deletions
+6 -4
View File
@@ -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>
);
+46 -15
View File
@@ -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">