From 2c41f2476b3b6f433855d3a634e750d8afad8cb6 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Thu, 30 May 2024 06:30:59 +0100 Subject: [PATCH] view all delete button for awaiting submission --- actions/index.js | 32 ++++-- components/myportal/viewall.js | 98 ++++++++++++++++++- components/utils/index.js | 39 ++++++-- data/formsxml/planningappeals78.xml | 2 +- .../pinswg_planningappeals78.json | 9 ++ i18n.js | 2 +- .../api/file/getawaitingsubmissionfromblob.js | 10 +- .../getawaitingsubmissionfromblobproxy.js | 45 +++++++++ 8 files changed, 211 insertions(+), 26 deletions(-) create mode 100644 pages/api/file/getawaitingsubmissionfromblobproxy.js diff --git a/actions/index.js b/actions/index.js index 28b413e9..56bcb920 100644 --- a/actions/index.js +++ b/actions/index.js @@ -862,8 +862,15 @@ export const getAwaitingSubmission = (loggedInUserId) => { export const getAwaitingSubmissionFromBlob = (containerName) => { console.log( "///////////////////////\ngetAwaitingSubmissionFromBlob: " + + containerName, + BASE_URL + + "/api/file/getawaitingsubmissionfromblob?container=" + containerName + - "\n///////////////////////\n" + hashAPIPath( + "/api/file/getawaitingsubmissionfromblob?container=" + + containerName + ), + "\n///////////////////////\n" ); return axios .get( @@ -915,15 +922,24 @@ export const getRepsFromBlob = (containerName) => { }; export const getAwaitingSubmissionFromBlobProxy = (containerName) => { + console.log( + "///////////////////////getAwaitingSubmissionFromBlobProxy: " + + containerName, + "/api/file/getawaitingsubmissionfromblobproxy?container=" + + containerName, + "\n///////////////////////\n" + ); + return axios .get( - BASE_URL + - "/api/file/getawaitingsubmissionfromblob?container=" + - containerName + - hashAPIPath( - "/api/file/getawaitingsubmissionfromblob?container=" + - containerName - ) + // BASE_URL + + "/api/file/getawaitingsubmissionfromblobproxy?container=" + + containerName + // + + // hashAPIPath( + // "/api/file/getawaitingsubmissionfromblob?container=" + + // containerName + // ) ) .then((res) => { return res.data; diff --git a/components/myportal/viewall.js b/components/myportal/viewall.js index 15eeffa8..392c0e6e 100644 --- a/components/myportal/viewall.js +++ b/components/myportal/viewall.js @@ -1,7 +1,6 @@ import Link from "next/link"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; -import { setCurrentReference } from "../../store/currentView/action"; import { connect } from "react-redux"; import { JSONPath as jsonpath } from "jsonpath-plus"; import transLookup from "../../data/lookuptranslations.json"; @@ -11,6 +10,32 @@ import { setSearchResults, setSearchDetails, } from "../../store/searchOutput/action"; +import { parseCookies, setCookie, destroyCookie } from "nookies"; +import { + getWatchedCasesProxy, + getPortalModuleDetailsProxy, + deleteWatchedCases, + deleteAwaitingSubmissions, + deleteAwaitingSubmissionsFromBlob, + getAwaitingSubmissionFromBlobProxy, + getAwaitingSubmissionProxy, +} from "../../actions"; +import { setAwaitingSubmissionFromBlob } from "../../store/awaitingSubmission/action"; + +import { + setWatchedCases, + setWatchedCasesDetails, +} from "../../store/watchedCases/action"; +import { + setAwaitingSubmission, + setAwaitingSubmissionDetails, +} from "../../store/awaitingSubmission/action"; + +import { + setCurrentLinkedCases, + setCurrentReference, + setCurrentView, +} from "../../store/currentView/action"; const ViewAllResults = (props) => { const { @@ -20,6 +45,9 @@ const ViewAllResults = (props) => { setCurrentReference, myportal, setSearchResults, + accountDetails, + setAwaitingSubmissionFromBlob, + setAwaitingSubmissionDetails, } = props; let { t } = useTranslation(); @@ -541,6 +569,34 @@ const ViewAllResults = (props) => { "statuscode@OData.Community.Display.V1.FormattedValue" ] || "N/A"} + {currentView.viewKey == "awaitingSubmissionDetails" && ( +
+ +
+ )} ); }); @@ -590,6 +646,29 @@ const ViewAllResults = (props) => { }; } + const deleteCaseItem = (containerID, caseID) => { + let cookies = parseCookies(); + console.log("sssss", containerID, caseID); + + deleteAwaitingSubmissionsFromBlob(containerID, caseID) + .then((data) => { + return data; + }) + .then(() => { + getAwaitingSubmissionFromBlobProxy(containerID) + .then((data) => { + setAwaitingSubmissionFromBlob(data); + setAwaitingSubmissionDetails(data); + }) + .then(() => { + setCurrentView({ + "viewName": "Awaiting Submission", + "viewKey": "awaitingSubmissionDetails", + }); + }); + }); + }; + return ( <>
@@ -777,6 +856,15 @@ const ViewAllResults = (props) => { ); }; +const mapStateToProps = (state) => { + return { + // currentView: state.currentView, + accountDetails: state.accountDetails, + // search: state.search, + // searchResultsObj: state.searchResultsObj, + }; +}; + const mapDispatchToProps = (dispatch) => { return { setCurrentReference: (currentReference) => { @@ -788,7 +876,13 @@ const mapDispatchToProps = (dispatch) => { setSearchDetails: (searchDetailsObj) => { dispatch(setSearchDetails(searchDetailsObj)); }, + setAwaitingSubmissionFromBlob: (awaitingSubmission) => { + dispatch(setAwaitingSubmissionFromBlob(awaitingSubmission)); + }, + setAwaitingSubmissionDetails: (awaitingSubmission) => { + dispatch(setAwaitingSubmissionDetails(awaitingSubmission)); + }, }; }; -export default connect(null, mapDispatchToProps)(ViewAllResults); +export default connect(mapStateToProps, mapDispatchToProps)(ViewAllResults); diff --git a/components/utils/index.js b/components/utils/index.js index 2159127f..91bc3619 100644 --- a/components/utils/index.js +++ b/components/utils/index.js @@ -316,15 +316,28 @@ export const getProgressObj = ( mandatoryFieldsData ); - if (datafieldname[0].value == "pinswg_fileUpload") { - return { - "fieldType": fieldtype[0].value, - "label": rows[0].value, - "datafieldname": datafieldname[0].value, - "key": key, - "picklistData": props.props.formData.pickListData, - "mandatoryFieldsData": mandatoryFieldsData, - }; + if (datafieldname[0].value.includes("pinswg_fileUpload")) { + if (typeof isRequiredField[0] != "undefined") { + if (isRequiredField[0].RequiredLevel.Value != "None") { + //console.log(datafieldname[0].value, validation); + return { + "fieldType": fieldtype[0].value, + "label": rows[0].value, + "datafieldname": datafieldname[0].value, + "datafieldcontent": datafieldcontent, + "validation": validation, + }; + } + } else { + return { + "fieldType": fieldtype[0].value, + "label": rows[0].value, + "datafieldname": datafieldname[0].value, + "key": key, + "picklistData": props.props.formData.pickListData, + "mandatoryFieldsData": mandatoryFieldsData, + }; + } } else { if (typeof isRequiredField[0] != "undefined") { if (isRequiredField[0].RequiredLevel.Value != "None") { @@ -350,6 +363,14 @@ export const getProgressObj = ( return el != null; }); + rowObj = rowObj.filter(function (el) { + return typeof el.validation != "undefined"; + }); + + rowObj = rowObj.filter(function (el) { + return el.validation.indexOf("required") > -1; + }); + const filterUnwanted = (rowObj) => { const required = rowObj.filter((el) => { return !_.isEmpty(el.validation); diff --git a/data/formsxml/planningappeals78.xml b/data/formsxml/planningappeals78.xml index 63dc4dbf..c83910c7 100644 --- a/data/formsxml/planningappeals78.xml +++ b/data/formsxml/planningappeals78.xml @@ -346,7 +346,7 @@ - + diff --git a/data/mandatoryfields/pinswg_planningappeals78.json b/data/mandatoryfields/pinswg_planningappeals78.json index 882a037b..e08911bb 100644 --- a/data/mandatoryfields/pinswg_planningappeals78.json +++ b/data/mandatoryfields/pinswg_planningappeals78.json @@ -1800,6 +1800,15 @@ "ManagedPropertyLogicalName": "canmodifyrequirementlevelsettings" }, "MetadataId": "8eb4ce7e-8f45-432c-8064-60405103e901" + }, + { + "LogicalName": "pinswg_fileUpload", + "RequiredLevel": { + "Value": "Recommended", + "CanBeChanged": true, + "ManagedPropertyLogicalName": "canmodifyrequirementlevelsettings" + }, + "MetadataId": "917f813a-4183-eb11-aac0-00224800be0c" } ] } \ No newline at end of file diff --git a/i18n.js b/i18n.js index 66ee181c..c2bc27ff 100644 --- a/i18n.js +++ b/i18n.js @@ -13,7 +13,7 @@ module.exports = { "/": ["common", "home", "case"], "/error": ["common", "home", "myportal"], "/myportal": ["myportal", "common", "home", "case"], - "/myportal/viewall": ["search", "myportal"], + "/myportal/viewall": ["search", "myportal", "case"], "/myportal/advancedsearch": ["search", "myportal"], "/myportal/advancedsearchresults": ["search", "myportal"], "/myportal/searchresults": ["search", "myportal", "case"], diff --git a/pages/api/file/getawaitingsubmissionfromblob.js b/pages/api/file/getawaitingsubmissionfromblob.js index 4660d3b8..085eb474 100644 --- a/pages/api/file/getawaitingsubmissionfromblob.js +++ b/pages/api/file/getawaitingsubmissionfromblob.js @@ -17,11 +17,11 @@ ApiProxy.get(async (req, res) => { var checkquerypath = "/api/file/getawaitingsubmissionfromblob?container=" + containerName; - // console.log( - // "///////////////////////\ngetawaitingsubmissionblob url :", - // req.url, - // "\n///////////////////////\n" - // ); + console.log( + "///////////////////////\ngetawaitingsubmissionblob url :", + req.url, + "\n///////////////////////\n" + ); // console.log(hashAPIPath(checkquerypath), checkHash); //console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash); diff --git a/pages/api/file/getawaitingsubmissionfromblobproxy.js b/pages/api/file/getawaitingsubmissionfromblobproxy.js new file mode 100644 index 00000000..6fb1b830 --- /dev/null +++ b/pages/api/file/getawaitingsubmissionfromblobproxy.js @@ -0,0 +1,45 @@ +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 checkHash = req.query.hash; + var token = await getToken(); + + var queryUrl = + "/api/file/getawaitingsubmissionfromblob?container=" + containerName; + + return axios + .get( + BASE_URL + queryUrl + hashAPIPath(queryUrl), + azureHeaders(token.access_token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch((err) => { + consoleLogger(err); + res.status(400).json(err); + }); +}