From 08ddfa386ac1273447338a9310b5c8c4d8ddef71 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Wed, 8 May 2024 10:05:11 +0100 Subject: [PATCH] added save button to save a partial rep before completion --- .gitignore | 3 +- actions/index.js | 2 +- components/case/representation/index.js | 104 +++++++++++++++++++++--- components/elements/index.js | 2 +- 4 files changed, 98 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index cd33d7ba..091823cf 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,5 @@ tmp docker dockerfile* .dockerignore -Makefile \ No newline at end of file +Makefile +docker*.yml \ No newline at end of file diff --git a/actions/index.js b/actions/index.js index 28b413e9..0f086e64 100644 --- a/actions/index.js +++ b/actions/index.js @@ -614,7 +614,7 @@ export const getLPA = () => { return axios .get(BASE_URL + "/api/endpoint/getlpa_api") .then((res) => { - //console.log(res.data); + console.log(res.data); return res.data; }) .catch((error) => { diff --git a/components/case/representation/index.js b/components/case/representation/index.js index a81ad932..1df6e770 100644 --- a/components/case/representation/index.js +++ b/components/case/representation/index.js @@ -48,6 +48,7 @@ let MakeRepresentation = (props) => { const { acceptedFiles, getRootProps, getInputProps } = useDropzone(); const [clearRepForm, setClearRepForm] = useState(false); + const [savingStatus, setSavingStatus] = useState(false); const { data: session } = useSession(); const router = useRouter(); @@ -389,6 +390,8 @@ let MakeRepresentation = (props) => { ) => { let incidentId = props.appealType.caseReference.incidentid; let updateBody = values || {}; + const buildFileArray = []; + setSavingStatus(useSaveStatus); // "pinswg_name": "2022-11-29-IP-REP_BOND_1", @@ -467,15 +470,42 @@ let MakeRepresentation = (props) => { "returnLink": "", "linkExpiry": 10 * 60, }; - props.currentView.representationSubmit == "true" && - (sendSavedEmail == true && - sendEmail(templateId, emailAddress, personalisation, reference), - useSaveStatus && - router.replace( - router.locale != "en" - ? router.locale + "/myportal" - : "/myportal" - )); + props.currentView.representationSubmit == "true" + ? (sendSavedEmail == true && + sendEmail( + templateId, + emailAddress, + personalisation, + reference + ), + useSaveStatus && + router.replace( + router.locale != "en" + ? router.locale + "/myportal" + : "/myportal" + )) + : useSaveStatus && + (values.hasOwnProperty("representationDocuments") && + (values.representationDocuments.map((Blob) => + buildFileArray.push({ + "name": Blob.name, + "size": Blob.size, + }) + ), + Object.assign(values, { + "filesList": buildFileArray, + })), + generateRepPDF( + values, + props.props.accountDetails.containerID, + currentView.caseReference.currentReference + ), + uploadRepresentationFiles(values), + router.replace( + router.locale != "en" + ? router.locale + "/myportal" + : "/myportal" + )); }; const onHandleSubmit = (values) => { @@ -752,7 +782,61 @@ let MakeRepresentation = (props) => { - + {" "} + {Object.keys( + props.props.currentView + .representationCapacity + ).length > 0 && + (savingStatus ? ( + + {router.locale == "cy" + ? "Nôl data" + : "Saving data"} + { + + ) : ( + + ))} {formObj.hasOwnProperty( "representationForm" ) && diff --git a/components/elements/index.js b/components/elements/index.js index 3f689ab9..b24946d6 100644 --- a/components/elements/index.js +++ b/components/elements/index.js @@ -537,7 +537,7 @@ const RenderDatePicker = ({ id={id + "_label"} htmlFor={id} > - {FieldsTranslations(label)} ssss + {FieldsTranslations(label)} {touched && error && (