diff --git a/actions/index.js b/actions/index.js index e25949f9..a753799c 100644 --- a/actions/index.js +++ b/actions/index.js @@ -1686,6 +1686,24 @@ export const getFilesFromBlob = (containerName, casefolderID) => { }); }; +export const getFilesFromBlobproxy = (containerName, casefolderID) => { + return axios + .get( + BASE_URL + + "/api/file/getbloblistproxy?container=" + + containerName + + "&casefolderID=" + + casefolderID + ) + .then((res) => { + //console.log("//////////----", res.data); + return res.data; + }) + .catch((error) => { + consoleLogger(error); + }); +}; + export const getFilesFromBlobHashed = ( containerName, getblobshash, diff --git a/components/elements/index.js b/components/elements/index.js index 00ac5a20..68d7b3bb 100644 --- a/components/elements/index.js +++ b/components/elements/index.js @@ -14,6 +14,7 @@ import { deleteBlob, getFilesFromBlobHashed, uploadSingleFile, + getFilesFromBlobproxy, } from "../../actions"; import fieldLookup from "../../data/crmfieldlookuptranslations.json"; import pickListLookup from "../../data/picklistLookups.json"; @@ -656,17 +657,20 @@ const RenderDatePicker = ({ )} - {touched && error && ( - - - Error: - {" "} - {errorMsg} - - )} + {!custom.hasOwnProperty("showErrorBottom") + ? touched && + error && ( + + + Error: + {" "} + {errorMsg} + + ) + : ""} {/* {value}
@@ -693,6 +697,20 @@ const RenderDatePicker = ({ autoComplete="off" //value={!value ? null : moment(value, "DD/MM/yyyy")} /> + {custom.hasOwnProperty("showErrorBottom") + ? touched && + error && ( + + + Error: + {" "} + {error} + + ) + : ""} @@ -1748,6 +1766,7 @@ export function FileUploadField(props) { containerID={props.containerID} uploadCount={props.uploadCount} setFileCount={props.setFileCount} + props={props.props} /> ); @@ -2023,7 +2042,53 @@ const RenderFileUpload = (field) => { field.ticketnumber ).then((data) => { console.log(data); - setCompletedUploadFiles(true); + let buildAppealFilesArray = []; + let values = field.form.appealForm.values; + let filesUploadObj = renamedAcceptedFiles; + + for (let key in filesUploadObj) { + typeof filesUploadObj[key].name != "undefined" && + buildAppealFilesArray.push({ + "name": filesUploadObj[key].name, + "size": filesUploadObj[key].size, + }); + } + + //console.log(buildAppealFilesArray); + function removeDuplicates(arr, key) { + const seen = new Set(); + return arr.filter((item) => { + const value = item[key]; + if (seen.has(value)) { + return false; // Duplicate found + } else { + seen.add(value); // Add value to the set + return true; // Keep the item + } + }); + } + + buildAppealFilesArray = values.hasOwnProperty( + "filesList" + ) + ? buildAppealFilesArray.concat(values.filesList) + : buildAppealFilesArray; + + buildAppealFilesArray = removeDuplicates( + buildAppealFilesArray, + "name" + ); + + Object.assign(values, { + "filesList": buildAppealFilesArray, + }); + getFilesFromBlobproxy( + field.containerID, + field.ticketnumber + ).then((data) => { + field.setFilesForAppeal(data); + setCompletedUploadFiles(true); + }); }); }} onDropRejected={handleDropRejected} @@ -2057,7 +2122,7 @@ const RenderFileUpload = (field) => { )} {completedUploadFiles > 0 && (
- {uploadCountMessage} files completed{" "} + {uploadCountMessage} files uploaded{" "}
)} @@ -2076,54 +2141,52 @@ const RenderFileUpload = (field) => { {field.meta.touched && field.meta.error && ( {field.meta.error} )} - {filesList.length > 0 && - (completedUploadFiles ? ( - "Done" - ) : ( -

Uploading

- ))} {files && Array.isArray(files) && ( <> {/* {(files = removeEmptyObjects(files))} */} -
- {files.map( - (file, i) => - typeof file.name != "undefined" && ( -
- {" "} - {} - removeFile(file)} + + {!completedUploadFiles && + files.map( + (file, i) => + typeof file.name != "undefined" && ( +
- − - - {file.name} - - {file.name} ({bytesToSize(file.size)}){" "} -
-
- {completedUploadFiles ? ( -

- Upload complete -

- ) : ( -

- Uploading... -

+ {" "} + {} + removeFile(file)} + > + − + + - -
- ) - )} + alt={file.name} + width="50" + /> + + {file.name} ( + {bytesToSize(file.size)})
+
+ {completedUploadFiles ? ( +

+ Upload complete +

+ ) : ( +

+ Uploading... +

+ )} +
+
+
+ ) + )} )} {blobList.length > 0 && ( @@ -2214,54 +2277,56 @@ const RenderSubFields = ({ fields, meta: { touched, error }, ...custom }) => { return errors; }; + const required = (value) => + value ? undefined : t("newappeal:is-required-label"); return ( -
); diff --git a/components/newappeal/buildsection.js b/components/newappeal/buildsection.js index 19a95cc3..f5a0e15d 100644 --- a/components/newappeal/buildsection.js +++ b/components/newappeal/buildsection.js @@ -173,143 +173,124 @@ let BuildSection = (props) => { setSavingStatus(useSaveStatus); - setShowCompletedUploadFiles(true); + //not sure we need this here if it does it on drop of file + //uploadAppealFiles(values); - uploadAppealFiles(values) - .then((data) => { - // console.log( - // "\n////////////////////////\n appeal pdf payload", - // values, - // props.props.accountDetails.containerID, - // props.appealType.caseReference.ticketnumber, - // props.appealType, - // "\n////////////////////////\n" - // ); + // console.log( + // "\n////////////////////////\n appeal pdf payload", + // values, + // props.props.accountDetails.containerID, + // props.appealType.caseReference.ticketnumber, + // props.appealType, + // "\n////////////////////////\n" + // ); - // let pdfObj = values; + // let pdfObj = values; - // Object.assign(pdfObj, { - // "containerID": props.props.accountDetails.containerID, - // "casefolderID": props.appealType.caseReference.ticketnumber, - // }); + // Object.assign(pdfObj, { + // "containerID": props.props.accountDetails.containerID, + // "casefolderID": props.appealType.caseReference.ticketnumber, + // }); - // generateAppealPDF( - // pdfObj, - // props.props.accountDetails.containerID, - // props.appealType.caseReference.ticketnumber, - // router.query.appealtypes, - // props.appealType.fileList - // ), + // generateAppealPDF( + // pdfObj, + // props.props.accountDetails.containerID, + // props.appealType.caseReference.ticketnumber, + // router.query.appealtypes, + // props.appealType.fileList + // ), - props.setNewAppealProgress( - getProgressObj( - formXML, - titleList, - mandatoryFieldsData, - props - ) - ); + props.setNewAppealProgress( + getProgressObj(formXML, titleList, mandatoryFieldsData, props) + ); - let appTypeCollection = getFormCollectionByID( - props.appealType.appealTypeID - ); - let updateBindAppealTypeToIncident = - appTypeCollection.NavigationProperty; + let appTypeCollection = getFormCollectionByID( + props.appealType.appealTypeID + ); + let updateBindAppealTypeToIncident = + appTypeCollection.NavigationProperty; - Object.assign(updateBody, { - "pinswg_appealcasetype": props.appealType.appealTypeID, - "pinswg_Appellant@odata.bind": - "/contacts(" + - props.props.accountDetails.loggedinUserId + - ")", - "pinswg_name": props.appealType.caseReference.ticketnumber, - [updateBindAppealTypeToIncident + "@odata.bind"]: - "/incidents(" + incidentId + ")", - }); + Object.assign(updateBody, { + "pinswg_appealcasetype": props.appealType.appealTypeID, + "pinswg_Appellant@odata.bind": + "/contacts(" + props.props.accountDetails.loggedinUserId + ")", + "pinswg_name": props.appealType.caseReference.ticketnumber, + [updateBindAppealTypeToIncident + "@odata.bind"]: + "/incidents(" + incidentId + ")", + }); - updateBody = JSON.stringify(updateBody); - updateBody = updateBody.replace(/:"Yes"/gm, `:true`); - updateBody = updateBody.replace(/:"No"/gm, `:false`); - updateBody = JSON.parse(updateBody); + updateBody = JSON.stringify(updateBody); + updateBody = updateBody.replace(/:"Yes"/gm, `:true`); + updateBody = updateBody.replace(/:"No"/gm, `:false`); + updateBody = JSON.parse(updateBody); - Object.keys(updateBody).forEach((key) => { - if (updateBody[key] === null) { - delete updateBody[key]; - } - if (key.indexOf("_") == 0) { - delete updateBody[key]; - } - }); + Object.keys(updateBody).forEach((key) => { + if (updateBody[key] === null) { + delete updateBody[key]; + } + if (key.indexOf("_") == 0) { + delete updateBody[key]; + } + }); - //console.log(updateBody); + //console.log(updateBody); - let updateFormCollection = - appTypeCollection.LogicalCollectionName; - let primaryAttribute = appTypeCollection.PrimaryIdAttribute; + let updateFormCollection = appTypeCollection.LogicalCollectionName; + let primaryAttribute = appTypeCollection.PrimaryIdAttribute; - const reference = "PEDW-PARTIAL"; - const templateId = "021b0a7b-df00-41f1-b94e-c269bee98c75"; - const templateIdCY = "f3c4a56b-bfb8-4d39-97dd-888df3062b0a"; - const emailAddress = - props.props.accountDetails.loggedinUserEmail; - const personalisation = { - "caseReference": - props.appealType.caseReference.ticketnumber, - "emailAddress": - props.props.accountDetails.loggedinUserEmail, - "returnLink": - props.props.url + - (router.locale != "en" - ? "/cy/fymhorth/" - : "/myportal/") + - appTypeCollection.UrlName + - "?lpa=" + - props.appealType.appealLPA + - "&apt=" + - appTypeCollection.appealTypeID + - "&casereference=" + - props.appealType.caseReference.ticketnumber + - "&inid=" + - props.appealType.caseReference.incidentid, - "linkExpiry": 10 * 60, - }; + const reference = "PEDW-PARTIAL"; + const templateId = "021b0a7b-df00-41f1-b94e-c269bee98c75"; + const templateIdCY = "f3c4a56b-bfb8-4d39-97dd-888df3062b0a"; + const emailAddress = props.props.accountDetails.loggedinUserEmail; + const personalisation = { + "caseReference": props.appealType.caseReference.ticketnumber, + "emailAddress": props.props.accountDetails.loggedinUserEmail, + "returnLink": + props.props.url + + (router.locale != "en" ? "/cy/fymhorth/" : "/myportal/") + + appTypeCollection.UrlName + + "?lpa=" + + props.appealType.appealLPA + + "&apt=" + + appTypeCollection.appealTypeID + + "&casereference=" + + props.appealType.caseReference.ticketnumber + + "&inid=" + + props.appealType.caseReference.incidentid, + "linkExpiry": 10 * 60, + }; - // console.log( - // "/////////////////////////////////", - // "returnLink:", - // props.props.url + - // (router.locale != "en" ? "/cy/fymhorth/" : "/myportal/") + - // appTypeCollection.UrlName + - // "?lpa=" + - // props.appealType.appealLPA + - // "&apt=" + - // appTypeCollection.appealTypeID + - // "&casereference=" + - // props.appealType.caseReference.ticketnumber + - // "&inid=" + - // props.appealType.caseReference.incidentid, - // "/////////////////////////////////" - // ); - }) - .then(() => { - sendSavedEmail == true && - sendEmail( - router.locale != "en" ? templateIdCY : templateId, - emailAddress, - personalisation, - reference - ); + // console.log( + // "/////////////////////////////////", + // "returnLink:", + // props.props.url + + // (router.locale != "en" ? "/cy/fymhorth/" : "/myportal/") + + // appTypeCollection.UrlName + + // "?lpa=" + + // props.appealType.appealLPA + + // "&apt=" + + // appTypeCollection.appealTypeID + + // "&casereference=" + + // props.appealType.caseReference.ticketnumber + + // "&inid=" + + // props.appealType.caseReference.incidentid, + // "/////////////////////////////////" + // ); - useSaveStatus && - router.replace( - router.locale != "en" - ? "/" + router.locale + "/myportal" - : "/myportal" - ); - }) - .then(() => { - setCompletedUploadFiles(true); - }); + sendSavedEmail == true && + sendEmail( + router.locale != "en" ? templateIdCY : templateId, + emailAddress, + personalisation, + reference + ); + + useSaveStatus && + router.replace( + router.locale != "en" + ? "/" + router.locale + "/myportal" + : "/myportal" + ); }; const onHandleSubmit = (values) => { @@ -617,7 +598,7 @@ let BuildSection = (props) => { "_pinswg_appellant_value" ]; - console.log("on save:", valuesObj); + //console.log("on save:", valuesObj); updateCaseProgress( valuesObj, true, diff --git a/locales/cy/newappeal.json b/locales/cy/newappeal.json index dee9e91f..5f2b5490 100644 --- a/locales/cy/newappeal.json +++ b/locales/cy/newappeal.json @@ -111,5 +111,5 @@ "planning-obligation-(s106/unilateral)": "Rhwymedigaeth gynllunio (S106/Unochrog)", "site-location-plan": "Cynllun Lleoliad Safle", "registration-of-application-letter": "Llythyr Cofrestru Cais", - "previously-added-files": "Ffeiliau a ychwanegwyd yn flaenorol" + "previously-added-files": "Ffeiliau wedi'u llwytho i fyny" } \ No newline at end of file diff --git a/locales/en/newappeal.json b/locales/en/newappeal.json index c50f2ff9..0143ee98 100644 --- a/locales/en/newappeal.json +++ b/locales/en/newappeal.json @@ -111,5 +111,5 @@ "planning-obligation-(s106/unilateral)": "Planning obligation (S106/Unilateral)", "site-location-plan": "Site Location Plan", "registration-of-application-letter": "Registration of Application letter", - "previously-added-files": "Previously added files" + "previously-added-files": "Uploaded files" } \ No newline at end of file diff --git a/pages/api/file/getbloblistproxy.js b/pages/api/file/getbloblistproxy.js new file mode 100644 index 00000000..65e8d007 --- /dev/null +++ b/pages/api/file/getbloblistproxy.js @@ -0,0 +1,49 @@ +import { + downloadAllProgressFiles, + getAllProgressBlobs, +} from "../../../actions/azurestorage"; +import _ from "lodash"; +import nextConnect from "next-connect"; +import middleware from "../middleware/middleware"; +import { + getToken, + azureHeaders, + consoleLogger, + hashAPIPath, +} from "../../../actions"; +import axios from "axios"; +import CryptoJS from "crypto-js"; + +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const BASE_URL = process.env.API_ROOT || `http://localhost:${port}`; + +export default async function ApiProxy(req, res) { + var containerName = req.query.container; + var casefolderID = req.query.casefolderID; + var checkHash = req.query.hash; + var token = await getToken(); + + var queryUrl = + "/api/file/getbloblist?container=" + + containerName + + "&casefolderID=" + + casefolderID; + + return axios + .get( + BASE_URL + queryUrl + hashAPIPath(queryUrl), + azureHeaders(token.access_token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch((error) => { + consoleLogger(error); + res.status(400).json(error); + }); +} diff --git a/styles/sass/welshgov/_application.scss b/styles/sass/welshgov/_application.scss index ffec544c..3b0933e9 100644 --- a/styles/sass/welshgov/_application.scss +++ b/styles/sass/welshgov/_application.scss @@ -2483,6 +2483,7 @@ ul#sharePageLinks.active { } } + // modal timeout .modal { @@ -2655,6 +2656,10 @@ fade { display: flex; flex-direction: row; align-items: center; + + .govuk-summary-list__actionLink.watched_link { + width: 10px; + } } @@ -2904,4 +2909,10 @@ fade { } } + + +} + +ul.subFieldList { + padding-left: 0; } \ No newline at end of file