uat fixes

This commit is contained in:
2024-11-27 11:00:12 +00:00
parent 630ed8d32b
commit 85f323d580
16 changed files with 284 additions and 137 deletions
+87 -40
View File
@@ -313,6 +313,26 @@ let BuildSection = (props) => {
// Object.assign(values, { "filesList": buildAppealFilesArray });
// Function to parse a specific key (e.g., 'price') in an array of objects
const parseFloatForKeyInObject = (obj, key) => {
// Check if the object has the key and the value can be parsed as a float
if (
obj.hasOwnProperty(key) &&
typeof obj[key] === "string" &&
!isNaN(obj[key].trim())
) {
// Parse the value as a float and update the object
return { ...obj, [key]: parseFloat(obj[key]) };
}
// If the key doesn't exist or value can't be parsed, return the original object
return obj;
};
valuesObj = parseFloatForKeyInObject(
valuesObj,
"pinswg_areaofsiteinhectaresdec"
);
delete valuesObj["_pinswg_appellant_value"];
//console.log("has errors:", props.invalid);
props.invalid == false && updateCaseProgress(valuesObj, false, false);
@@ -440,53 +460,56 @@ let BuildSection = (props) => {
false,
false
);
// currentSection == 1 &&
// setCurrentSection(1);
}}
>
{t("common:continue-button")}
</button>
{savingStatus ? (
<span className=" progress-save-active">
{router.locale == "cy"
? "Nôl data"
: "Saving data"}
<img
className="data-loading-icon"
src="/assets/images/loading.gif"
alt={
router.locale == "cy"
? "Nôl data"
: "Saving data"
}
/>
</span>
) : (
<button
className="govuk-button progress-save "
onClick={() => {
let valuesObj =
props.props.form[props.form]
.values || {};
{currentSection > 1 &&
(savingStatus ? (
<span className=" progress-save-active">
{router.locale == "cy"
? "Nôl data"
: "Saving data"}
<img
className="data-loading-icon"
src="/assets/images/loading.gif"
alt={
router.locale == "cy"
? "Nôl data"
: "Saving data"
}
/>
</span>
) : (
<button
className="govuk-button progress-save "
onClick={() => {
let valuesObj =
props.props.form[props.form]
.values || {};
// console.log(
// "valuesobj:",
// valuesObj
// );
// console.log(
// "valuesobj:",
// valuesObj
// );
delete valuesObj[
"_pinswg_appellant_value"
];
delete valuesObj[
"_pinswg_appellant_value"
];
// console.log("on save:", valuesObj);
updateCaseProgress(
valuesObj,
true,
true
);
}}
>
{t("common:save-exit-button")}
</button>
)}
// console.log("on save:", valuesObj);
updateCaseProgress(
valuesObj,
true,
true
);
}}
>
{t("common:save-exit-button")}
</button>
))}
{/* <span
onClick={() =>
setCurrentSection(sectionCount + 1)
@@ -669,6 +692,29 @@ const mapDispatchToProps = (dispatch) => {
const selector = formValueSelector("appealForm"); // <-- same as form name
const validate = (values) => {
const errors = {};
const strippedHtml = (htmlStr) => {
return htmlStr.replace(/(<([^>]+)>)/gi, "").trim();
};
if (values.hasOwnProperty("pinswg_attachsoc")) {
if (values.pinswg_attachsoc == "false") {
if (values.hasOwnProperty("pinswg_statementofcase")) {
if (strippedHtml(values.pinswg_statementofcase).length == 0)
errors.pinswg_statementofcase =
"Enter submit a statement of case or select Yes to attach a separate Statement of Case Document";
} else {
errors.pinswg_statementofcase =
"Enter submit a statement of case or select Yes to attach a separate Statement of Case Document";
}
}
}
return errors;
};
export default connect(
mapStateToProps,
mapDispatchToProps
@@ -677,5 +723,6 @@ export default connect(
form: "appealForm",
destroyOnUnmount: false,
enableReinitialize: true, // this is needed!!
validate,
})(BuildSection)
);