From 287da16b8a8125bbb1d91e22de39db77bef6aaf2 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Fri, 24 Sep 2021 15:31:08 +0100 Subject: [PATCH 1/2] added in documents for case and onlu published --- actions/index.js | 141 ++--- components/case.js | 9 +- components/case/documents.js | 179 ++++-- components/case/summary.js | 896 ++++++++++++++++------------- components/search/searchresults.js | 1 + data/lookuptranslations.json | 57 ++ pages/advancedsearchresults.js | 64 ++- pages/case.js | 7 + pages/searchresults.js | 72 ++- store/searchOutput/action.js | 15 + store/searchOutput/reducer.js | 12 + 11 files changed, 905 insertions(+), 548 deletions(-) diff --git a/actions/index.js b/actions/index.js index 9d01abf4..76916c5a 100644 --- a/actions/index.js +++ b/actions/index.js @@ -145,15 +145,15 @@ export const getBasicSearch = (token, searchString) => { WEBAPI_URL + "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=contains(title, '" + searchString + - "') and pinswg_appealcasetype ne null &$orderby=createdon desc&$count=true&$top=201", + "') and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true&$top=201", azureHeaders(token) ) .then((res) => { - console.log(" "); - console.log("/////////////////////"); - console.log("data:" + res.data.value); - console.log("/////////////////////"); - console.log(" "); + // console.log(" "); + // console.log("/////////////////////"); + // console.log("data:" + res.data.value); + // console.log("/////////////////////"); + // console.log(" "); return res.data; }) .catch((error) => { @@ -165,7 +165,7 @@ export const getBasicDNSSearch = (token, searchString) => { return axios .get( WEBAPI_URL + - "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011&$orderby=createdon desc&$count=true", + "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true", azureHeaders(token) ) .then((res) => res.data) @@ -210,7 +210,7 @@ export const getAdvancedSearch = (token, searchString) => { WEBAPI_URL + "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title&$filter=" + queryString + - " and pinswg_appealcasetype ne null &$orderby=createdon desc&$count=true&$top=201", + " and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true&$top=201", azureHeaders(token) ) @@ -236,6 +236,35 @@ export const getBasicSearchDetails = (token, appealType, caseReference) => { }); }; +export const getSearchDocumentDetails = (token, incidentID) => { + return axios + .get( + WEBAPI_URL + + "pinswg_documents?$count=true&$filter=_pinswg_documentids_value eq " + + incidentID + + " and pinswg_publishtoweb eq true&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference", + azureHeaders(token) + ) + .then((res) => res.data) + .catch((error) => { + console.log("thiserror", error); + }); +}; + +export const getSearchDocumentHistory = (token, documentID) => { + return axios + .get( + WEBAPI_URL + + "pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " + + documentID, + azureHeaders(token) + ) + .then((res) => res.data) + .catch((error) => { + console.log("thiserror", error); + }); +}; + export const getBasicDNSSearchDetails = (token, appealType, caseReference) => { return axios .get( @@ -311,64 +340,6 @@ export const getAppealsTypes = (token) => { }); }; -export const getBasicSearch2 = (searchString) => { - var req = new XMLHttpRequest(); - req.open( - "GET", - "https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v8.2/incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title&$filter=contains(title, '" + - searchString + - "')&$count=true", - true - ); - req.setRequestHeader("OData-MaxVersion", "4.0"); - req.setRequestHeader("OData-Version", "4.0"); - req.setRequestHeader("Accept", "application/json"); - req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); - req.setRequestHeader("Prefer", 'odata.include-annotations="*"'); - req.onreadystatechange = function () { - if (this.readyState === 4) { - req.onreadystatechange = null; - if (this.status === 200) { - var results = JSON.parse(this.response); - var recordCount = results["@odata.count"]; - for (var i = 0; i < results.value.length; i++) { - var _accountid_value = results.value[i]["_accountid_value"]; - var _accountid_value_formatted = - results.value[i][ - "_accountid_value@OData.Community.Display.V1.FormattedValue" - ]; - var _accountid_value_lookuplogicalname = - results.value[i][ - "_accountid_value@Microsoft.Dynamics.CRM.lookuplogicalname" - ]; - var _customerid_value = - results.value[i]["_customerid_value"]; - var _customerid_value_formatted = - results.value[i][ - "_customerid_value@OData.Community.Display.V1.FormattedValue" - ]; - var _customerid_value_lookuplogicalname = - results.value[i][ - "_customerid_value@Microsoft.Dynamics.CRM.lookuplogicalname" - ]; - var pinswg_appealcasetype = - results.value[i]["pinswg_appealcasetype"]; - var pinswg_appealcasetype_formatted = - results.value[i][ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ]; - var statuscode = results.value[i]["statuscode"]; - var ticketnumber = results.value[i]["ticketnumber"]; - var title = results.value[i]["title"]; - } - } else { - console.log(this.statusText); - } - } - }; - return req.send(); -}; - //get list of entitydefinitions //https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v8.2/EntityDefinitions?$select=LogicalName @@ -393,25 +364,24 @@ export const getBasicSearch2 = (searchString) => { // // Failed // }); -export const getAppealTypeDetail = (caseReference, appealcasetype) => { - console.log("got to axios", searchString); - console.log("api_root: ", BASE_URL); - // example appealcasetype type pinswg_householderappealhases - return axios - .get( - "https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v8.2/" + - appealcasetype + - "?$filter=pinswg_name eq '" + - caseReference + - "'", - { httpsAgent: new https.Agent({ rejectUnauthorized: false }) } - ) - .then((res) => res.data) - .catch((error) => { - console.log("thi serror", error); - }); -}; -//https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v8.2/pinswg_planningappeals78s?$filter=pinswg_name eq 'CAS-00015-L7J9H1' +// export const getAppealTypeDetail = (caseReference, appealcasetype) => { +// console.log("got to axios", searchString); +// console.log("api_root: ", BASE_URL); +// // example appealcasetype type pinswg_householderappealhases +// return axios +// .get( +// "https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v8.2/" + +// appealcasetype + +// "?$filter=pinswg_name eq '" + +// caseReference + +// "'", +// { httpsAgent: new https.Agent({ rejectUnauthorized: false }) } +// ) +// .then((res) => res.data) +// .catch((error) => { +// console.log("thi serror", error); +// }); +// }; export const getLPA = (token) => { // console.log("api_root: ", BASE_URL); @@ -472,6 +442,7 @@ export const createCase = (appealTypeId) => { appealTypeId = parseInt(appealTypeId); var data = JSON.stringify({ "title": "insertion test case", + "caseorigincode": 3, "customerid_contact@odata.bind": "/contacts(f8b454ed-eded-eb11-aac7-00224800be9c)", "pinswg_appealcasetype": appealTypeId, diff --git a/components/case.js b/components/case.js index 3f82e98c..1a9feb83 100644 --- a/components/case.js +++ b/components/case.js @@ -31,7 +31,14 @@ const CaseSummary = (props) => { searchDetailsObj={props.searchDetailsObj} searchString={props.searchString} /> - + diff --git a/components/case/documents.js b/components/case/documents.js index 96a0b42f..b72cd073 100644 --- a/components/case/documents.js +++ b/components/case/documents.js @@ -1,65 +1,150 @@ import Link from "next/link"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; +import jsonpath from "jsonpath"; -export default function CaseSummary() { +const DocumentDetails = (props) => { let { t } = useTranslation(); + const { + incidentid, + caseReference, + searchResultsObj, + searchDetailsObj, + documentDetailsObj, + documentHistoryObj, + } = props; + const router = useRouter(); const { locale } = router; + + var documentDetailsArr = documentDetailsObj || []; + + console.log(documentDetailsObj); + console.log(documentDetailsArr); + + const DocumentView = (documentDetailsArr) => { + return ( +
+
+
+ {t("case:documents-name-label")} +
+
+ {t("case:documents-doc-type-label")} +
+
+ {t("case:documents-date-published-label")} +
+
+ {t("case:documents-size-label")} +
+
+ + {documentDetailsArr.map((item, key) => { + console.log(key); + let detailsObj = jsonpath.query( + documentDetailsObj[key], + "$..value[?(@._pinswg_documentids_value=='" + + incidentid + + "')]" + ); + detailsObj = detailsObj[0]; + + if (typeof detailsObj != "undefined") { + var documentHistoryArr = documentHistoryObj || []; + return documentHistoryArr.map((historyItem, key) => { + let historyObj = jsonpath.query( + documentHistoryObj[key], + "$..value[?(@._pinswg_documentid_value=='" + + detailsObj.pinswg_documentid + + "')]" + ); + return ( +
+
+ + + + {t( + "case:documents-name-label" + )} + : + + {_.has(historyObj[key], [ + "_pinswg_documentid_value@OData.Community.Display.V1.FormattedValue", + ]) + ? historyObj[key][ + "_pinswg_documentid_value@OData.Community.Display.V1.FormattedValue" + ] + : ""} + + +
+
+ + {t("case:documents-doc-type-label")} + : + + { + detailsObj[ + "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue" + ] + } +
+
+ + {t( + "case:documents-date-published-label" + )} + : + + + {_.has(historyObj[key], [ + "pinswg_publisheddate@OData.Community.Display.V1.FormattedValue", + ]) + ? historyObj[key][ + "pinswg_publisheddate@OData.Community.Display.V1.FormattedValue" + ] + : ""} +
+
+ + {t("case:documents-size-label")}: + + 92 +
+
+ ); + }); + } + })} +
+ ); + }; + return (

Documents

-
-
-
- {t("case:documents-name-label")} -
-
- {t("case:documents-doc-type-label")} -
-
- {t("case:documents-date-published-label")} -
-
- {t("case:documents-size-label")} -
+ {console.log(documentDetailsObj)} + {documentDetailsArr.length > 0 ? ( + DocumentView(documentDetailsArr) + ) : ( +
+
+

There are no documents for this appeal

+
-
-
- - - - {t("case:documents-name-label")}: - - 3272770 Appeal Decision.pdf - - -
-
- - {t("case:documents-doc-type-label")}: - - Outcome / Decision -
-
- - {t("case:documents-date-published-label")}: - - 15/06/2021 -
-
- - {t("case:documents-size-label")}: - - 92 -
-
-
+ )}
); -} +}; + +export default DocumentDetails; diff --git a/components/case/summary.js b/components/case/summary.js index 8979051d..f3956b31 100644 --- a/components/case/summary.js +++ b/components/case/summary.js @@ -1,9 +1,11 @@ import Link from "next/link"; import { useRouter } from "next/router"; +import { useState } from "react"; import useTranslation from "next-translate/useTranslation"; import jsonpath from "jsonpath"; import _ from "lodash"; import transLookup from "../../data/lookuptranslations.json"; +import LoadingOverlay from "react-loading-overlay"; const CaseSummary = (props) => { let { t } = useTranslation(); @@ -53,151 +55,172 @@ const CaseSummary = (props) => { )); detailsObj = detailsObj[0]; - return ( -
-
-
-

- Reference:{" "} - {currentType == "searchResultsObj" - ? detailsObj.pinswg_name - : casesObj.reference} -

-
-
-
- {t("case:summary-applicant-label")} -
-
- {detailsObj[ - "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue" - ] || "not entered"} -
-
- {_.has(detailsObj, "pinswg_agentcontactname") ? ( + let showDetails = typeof detailsObj != "undefined" ? true : false; + + let showDetailsBlock = + showDetails == true ? ( +
+
+
+

+ Reference:{" "} + {currentType == "searchResultsObj" + ? detailsObj.pinswg_name + : casesObj.reference} +

+ +
- {t("case:summary-agent-label")} + {t("case:summary-applicant-label")} +
+
+ {detailsObj[ + "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue" + ] || "not entered"} +
+
+ {_.has(detailsObj, "pinswg_agentcontactname") ? ( +
+
+ {t("case:summary-agent-label")} +
+
+ {_.has( + detailsObj, + "pinswg_agentcontactname" + ) + ? detailsObj.pinswg_agentcontactname + : ""} +
+
+ ) : ( + "" + )} +
+
+ {t("case:summary-site-address-label")}
{_.has( detailsObj, - "pinswg_agentcontactname" + "pinswg_siteaddressline1" ) - ? detailsObj.pinswg_agentcontactname + ? detailsObj.pinswg_siteaddressline1 + : ""} +
+ {_.has( + detailsObj, + "pinswg_siteaddressline2" + ) + ? detailsObj.pinswg_siteaddressline2 + : ""} +
+ {_.has(detailsObj, "pinswg_siteaddresstown") + ? detailsObj.pinswg_siteaddresstown + : ""} +
+ {_.has( + detailsObj, + "pinswg_siteaddresscounty" + ) + ? detailsObj.pinswg_siteaddresscounty + : ""} +
+ {_.has( + detailsObj, + "pinswg_siteaddresspostcode" + ) + ? detailsObj.pinswg_siteaddresspostcode : ""}
- ) : ( - "" - )} -
-
- {t("case:summary-site-address-label")} -
-
- {_.has(detailsObj, "pinswg_siteaddressline1") - ? detailsObj.pinswg_siteaddressline1 - : ""} -
- {_.has(detailsObj, "pinswg_siteaddressline2") - ? detailsObj.pinswg_siteaddressline2 - : ""} -
- {_.has(detailsObj, "pinswg_siteaddresstown") - ? detailsObj.pinswg_siteaddresstown - : ""} -
- {_.has(detailsObj, "pinswg_siteaddresscounty") - ? detailsObj.pinswg_siteaddresscounty - : ""} -
- {_.has(detailsObj, "pinswg_siteaddresspostcode") - ? detailsObj.pinswg_siteaddresspostcode - : ""} -
-
-
-
-
-
-
-
-
-
-
-
-

- {t("case:summary-case-details-label")} -

+
+
+
+ {noRepresentationLink.includes(router.pathname) == + true ? ( + "" + ) : ( + + + {t( + "case:summary-make-representation-label" + )} + + + )} -
-
-
- {t("case:summary-case-type-label")} -
-
- {router.locale == "cy" - ? jsonpath.query( - transLookup, - '$..[?(@.value=="' + - casesObj[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy' - ) - : casesObj[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-date-entered-label" - )} -
-
-
-
- {t("case:summary-lpa-label")} -
-
- {router.locale == "cy" - ? jsonpath.query( - transLookup, - '$..[?(@.value=="' + - detailsObj[ - "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy' - ) - : detailsObj[ - "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ] || ""} -
-
- {/* +
+
+
+
+
+
+
+

+ {t("case:summary-case-details-label")} +

+ +
+
+
+ {t( + "case:summary-case-type-label" + )} +
+
+ {router.locale == "cy" + ? jsonpath.query( + transLookup, + '$..[?(@.value=="' + + casesObj[ + "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + ] + + '")].value_cy' + ) + : casesObj[ + "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + ] || + t( + "case:summary-no-date-entered-label" + )} +
+
+
+
+ {t("case:summary-lpa-label")} +
+
+ {router.locale == "cy" + ? jsonpath.query( + transLookup, + '$..[?(@.value=="' + + detailsObj[ + "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" + ] + + '")].value_cy' + ) + : detailsObj[ + "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" + ] || ""} +
+
+ {/*
{t( "case:summary-case-summary-label" @@ -212,309 +235,362 @@ const CaseSummary = (props) => { : ""}
*/} -
-
- {t( - "case:summary-case-officer-label" - )} -
-
- {" "} - {/* {casesObj.caseDetails.caseOfficer || +
+
+ {t( + "case:summary-case-officer-label" + )} +
+
+ {" "} + {/* {casesObj.caseDetails.caseOfficer || ""} */} - {_.has( - detailsObj, - "pinswg_casedescription" - ) - ? detailsObj.pinswg_casedescription - : ""} -
-
-
-
- {t("case:summary-procedure-label")} -
-
- {router.locale == "cy" - ? jsonpath.query( - transLookup, - '$..[?(@.value=="' + - detailsObj[ - "pinswg_procedure@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy' - ) - : detailsObj[ - "pinswg_procedure@OData.Community.Display.V1.FormattedValue" - ] || ""} -
-
-
-
- {t("case:summary-status-label")} -
-
- {router.locale == "cy" - ? jsonpath.query( - transLookup, - '$..[?(@.value=="' + - casesObj[ - "statuscode@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy' - ) - : casesObj[ - "statuscode@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-date-entered-label" - )} -
-
-
-
- {t("case:summary-decision-label")} -
-
- {router.locale == "cy" - ? jsonpath.query( - transLookup, - '$..[?(@.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy' - ) - : detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-date-entered-label" - )} + {_.has( + detailsObj, + "pinswg_casedescription" + ) + ? detailsObj.pinswg_casedescription + : ""} +
+
+
+
+ {t( + "case:summary-procedure-label" + )} +
+
+ {router.locale == "cy" + ? jsonpath.query( + transLookup, + '$..[?(@.value=="' + + detailsObj[ + "pinswg_procedure@OData.Community.Display.V1.FormattedValue" + ] + + '")].value_cy' + ) + : detailsObj[ + "pinswg_procedure@OData.Community.Display.V1.FormattedValue" + ] || ""} +
+
+
+
+ {t("case:summary-status-label")} +
+
+ {router.locale == "cy" + ? jsonpath.query( + transLookup, + '$..[?(@.value=="' + + casesObj[ + "statuscode@OData.Community.Display.V1.FormattedValue" + ] + + '")].value_cy' + ) + : casesObj[ + "statuscode@OData.Community.Display.V1.FormattedValue" + ] || + t( + "case:summary-no-date-entered-label" + )} +
+
+
+
+ {t( + "case:summary-decision-label" + )} +
+
+ {router.locale == "cy" + ? jsonpath.query( + transLookup, + '$..[?(@.value=="' + + detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ] + + '")].value_cy' + ) + : detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ] || + t( + "case:summary-no-date-entered-label" + )} -
- {/* +
+ {/* {casesObj.caseDetails .outcome_document || ""} */} -
-
-
-
- {t( - "case:summary-case-link-status-label" - )} -
-
- {_.has(detailsObj, [ - "pinswg_linkedstatus@OData.Community.Display.V1.FormattedValue", - ]) - ? detailsObj[ - "pinswg_linkedstatus@OData.Community.Display.V1.FormattedValue" - ] - : t( - "case:summary-case-link-status-not-linked" - )} -
-
-
-
- {t( - "case:summary-linked-cases-label" - )} -
-
- {/* {casesObj.caseDetails.linkedCases || +
+
+
+
+ {t( + "case:summary-case-link-status-label" + )} +
+
+ {_.has(detailsObj, [ + "pinswg_linkedstatus@OData.Community.Display.V1.FormattedValue", + ]) + ? detailsObj[ + "pinswg_linkedstatus@OData.Community.Display.V1.FormattedValue" + ] + : t( + "case:summary-case-link-status-not-linked" + )} +
+
+
+
+ {t( + "case:summary-linked-cases-label" + )} +
+
+ {/* {casesObj.caseDetails.linkedCases || ""} */} -
-
-
+ +
+ +
-
-
-
-
-

- {t("case:summary-dates-label")} -

-
-
-
- {t("case:summary-start-date-label")} -
-
- {_.has( - detailsObj, - "pinswg_startdate@OData.Community.Display.V1.FormattedValue" - ) - ? detailsObj[ - "pinswg_startdate@OData.Community.Display.V1.FormattedValue" - ] - : t( - "case:summary-no-date-entered-label" - )} -
-
+
+
+
+

+ {t("case:summary-dates-label")} +

+
+
+
+ {t( + "case:summary-start-date-label" + )} +
+
+ {_.has( + detailsObj, + "pinswg_startdate@OData.Community.Display.V1.FormattedValue" + ) + ? detailsObj[ + "pinswg_startdate@OData.Community.Display.V1.FormattedValue" + ] + : t( + "case:summary-no-date-entered-label" + )} +
+
-
-
- {t( - "case:summary-questionnaire-due-date-label" - )} -
-
- {_.has( - detailsObj, - "pinswg_questionnaireduedate@OData.Community.Display.V1.FormattedValue" - ) - ? detailsObj[ - "pinswg_questionnaireduedate@OData.Community.Display.V1.FormattedValue" - ] - : t( - "case:summary-no-date-entered-label" - )} -
-
+
+
+ {t( + "case:summary-questionnaire-due-date-label" + )} +
+
+ {_.has( + detailsObj, + "pinswg_questionnaireduedate@OData.Community.Display.V1.FormattedValue" + ) + ? detailsObj[ + "pinswg_questionnaireduedate@OData.Community.Display.V1.FormattedValue" + ] + : t( + "case:summary-no-date-entered-label" + )} +
+
-
-
- {t( - "case:summary-statement-due-date-label" - )} -
-
- {_.has( - detailsObj, - "pinswg_statementduedate@OData.Community.Display.V1.FormattedValue" - ) - ? detailsObj[ - "pinswg_statementduedate@OData.Community.Display.V1.FormattedValue" - ] - : t( - "case:summary-no-date-entered-label" - )} -
-
+
+
+ {t( + "case:summary-statement-due-date-label" + )} +
+
+ {_.has( + detailsObj, + "pinswg_statementduedate@OData.Community.Display.V1.FormattedValue" + ) + ? detailsObj[ + "pinswg_statementduedate@OData.Community.Display.V1.FormattedValue" + ] + : t( + "case:summary-no-date-entered-label" + )} +
+
-
-
- {t( - "case:summary-interested-party-date-label" - )} -
-
- {_.has( - detailsObj, - "pinswg_otherpartiesstatement@OData.Community.Display.V1.FormattedValue" - ) - ? detailsObj[ - "pinswg_otherpartiesstatement@OData.Community.Display.V1.FormattedValue" - ] - : t( - "case:summary-no-date-entered-label" - )} -
-
+
+
+ {t( + "case:summary-interested-party-date-label" + )} +
+
+ {_.has( + detailsObj, + "pinswg_otherpartiesstatement@OData.Community.Display.V1.FormattedValue" + ) + ? detailsObj[ + "pinswg_otherpartiesstatement@OData.Community.Display.V1.FormattedValue" + ] + : t( + "case:summary-no-date-entered-label" + )} +
+
-
-
- {t( - "case:summary-applicant-final-comments-date-label" - )} -
-
- {_.has( - detailsObj, - "pinswg_finalcommentsduedate@OData.Community.Display.V1.FormattedValue" - ) - ? detailsObj[ - "pinswg_finalcommentsduedate@OData.Community.Display.V1.FormattedValue" - ] - : t( - "case:summary-no-date-entered-label" - )} -
-
+
+
+ {t( + "case:summary-applicant-final-comments-date-label" + )} +
+
+ {_.has( + detailsObj, + "pinswg_finalcommentsduedate@OData.Community.Display.V1.FormattedValue" + ) + ? detailsObj[ + "pinswg_finalcommentsduedate@OData.Community.Display.V1.FormattedValue" + ] + : t( + "case:summary-no-date-entered-label" + )} +
+
-
-
- {t( - "case:summary-inquiry-evidence-date-label" - )} -
-
- {_.has( - detailsObj, - "pinswg_finalcommentsduedate@OData.Community.Display.V1.FormattedValue" - ) - ? detailsObj[ - "pinswg_finalcommentsduedate@OData.Community.Display.V1.FormattedValue" - ] - : t( - "case:summary-no-date-entered-label" - )} -
-
+
+
+ {t( + "case:summary-inquiry-evidence-date-label" + )} +
+
+ {_.has( + detailsObj, + "pinswg_finalcommentsduedate@OData.Community.Display.V1.FormattedValue" + ) + ? detailsObj[ + "pinswg_finalcommentsduedate@OData.Community.Display.V1.FormattedValue" + ] + : t( + "case:summary-no-date-entered-label" + )} +
+
-
-
- {t("case:summary-event-date-label")} -
-
- {_.has( - detailsObj, - "pinswg_dateeventrequested@OData.Community.Display.V1.FormattedValue" - ) - ? detailsObj[ - "pinswg_dateeventrequested@OData.Community.Display.V1.FormattedValue" - ] - : t( - "case:summary-no-date-entered-label" - )} -
-
+
+
+ {t( + "case:summary-event-date-label" + )} +
+
+ {_.has( + detailsObj, + "pinswg_dateeventrequested@OData.Community.Display.V1.FormattedValue" + ) + ? detailsObj[ + "pinswg_dateeventrequested@OData.Community.Display.V1.FormattedValue" + ] + : t( + "case:summary-no-date-entered-label" + )} +
+
-
-
- {t( - "case:summary-decision-date-label" - )} -
-
- {_.has( - detailsObj, - "pinswg_dateoflpadecision@OData.Community.Display.V1.FormattedValue" - ) - ? detailsObj[ - "pinswg_dateoflpadecision@OData.Community.Display.V1.FormattedValue" - ] - : t( - "case:summary-no-date-entered-label" - )} -
-
-
+
+
+ {t( + "case:summary-decision-date-label" + )} +
+
+ {_.has( + detailsObj, + "pinswg_dateoflpadecision@OData.Community.Display.V1.FormattedValue" + ) + ? detailsObj[ + "pinswg_dateoflpadecision@OData.Community.Display.V1.FormattedValue" + ] + : t( + "case:summary-no-date-entered-label" + )} +
+
+
+
- - {/*
-
-
- - - {t("case:summary-documents-button-label")} - - + ) : ( + <> +
+
+
+

Not details currently held

+
-
*/} -
+ + + ); + + const [showSpinnerState, setShowSpinnerState] = useState(false); + + let spinnerState = () => { + showSpinnerState == true + ? setShowSpinnerState(false) + : setShowSpinnerState(true); + }; + + return ( + <> + {showDetailsBlock} + {" "} + ); }; diff --git a/components/search/searchresults.js b/components/search/searchresults.js index f2066245..c283d830 100644 --- a/components/search/searchresults.js +++ b/components/search/searchresults.js @@ -62,6 +62,7 @@ const SearchResults = (props) => { "currentReference": item.title, "currentType": "searchResultsObj", + "incidentid": item.incidentid, }); }} > diff --git a/data/lookuptranslations.json b/data/lookuptranslations.json index 27d6418f..b8c4ed43 100644 --- a/data/lookuptranslations.json +++ b/data/lookuptranslations.json @@ -343,5 +343,62 @@ "value_cy": "Ymholiad", "pinswg_procedure": 0 } + ], + "pinswg_isharedocumentlocations": [ + { + "value": "Main Party - Pre-Submission Docs", + "value_cy": "Prif Blaid - Dociau Cyn Cyflwyno", + "pinswg_isharedocumentlocations": 0 + }, + { + "value": "Main Party - Submission Document", + "value_cy": "Prif Blaid - Dogfen Gyflwyno", + "pinswg_isharedocumentlocations": 0 + }, + { + "value": "Main Party - Questionnaire", + "value_cy": "Prif Blaid - Holiadur", + "pinswg_isharedocumentlocations": 0 + }, + { + "value": "Main Party - Statements", + "value_cy": "Prif Blaid - Datganiadau", + "pinswg_isharedocumentlocations": 0 + }, + { + "value": "Main Party - Comments", + "value_cy": "Prif Blaid - Sylwadau", + "pinswg_isharedocumentlocations": 0 + }, + { + "value": "Main Party - Written Statements of Evidence", + "value_cy": "Prif Blaid - Datganiadau Tystiolaeth Ysgrifenedig", + "pinswg_isharedocumentlocations": 0 + }, + { + "value": "Main Party - Environmental Statements", + "value_cy": "Prif Blaid - Datganiadau Amgylcheddol", + "pinswg_isharedocumentlocations": 0 + }, + { + "value": "Interested Party Representations", + "value_cy": "Cynrychioliadau Partïon â Diddordeb", + "pinswg_isharedocumentlocations": 0 + }, + { + "value": "Correspondence", + "value_cy": "Gohebiaeth", + "pinswg_isharedocumentlocations": 0 + }, + { + "value": "Inspector Notes", + "value_cy": "Nodiadau Arolygydd", + "pinswg_isharedocumentlocations": 0 + }, + { + "value": "Final Decision/Report", + "value_cy": "Penderfyniad / Adroddiad Terfyno", + "pinswg_isharedocumentlocations": 0 + } ] } \ No newline at end of file diff --git a/pages/advancedsearchresults.js b/pages/advancedsearchresults.js index e8665cb7..fd16a2d1 100644 --- a/pages/advancedsearchresults.js +++ b/pages/advancedsearchresults.js @@ -20,11 +20,15 @@ import { setSearch, getSearchObj } from "../store/search/action"; import { setSearchResults, setSearchDetails, + setDocumentDetails, + setDocumentHistory, getSearchResultsObj, } from "../store/searchOutput/action"; import { getAdvancedSearch, getBasicSearchDetails, + getSearchDocumentDetails, + getSearchDocumentHistory, getSASToken, } from "../actions"; @@ -74,10 +78,21 @@ export const getServerSideProps = wrapper.getServerSideProps( token, searchResultsObj ); - // console.log(searchDetailsObj); + const searchDocumentResultsObj = await getDocumentDetails( + token, + searchResultsObj + ); + + const searchDocumentHistoryObj = await getDocumentHistory( + token, + searchDocumentResultsObj + ); + //console.log(searchDocumentHistoryObj); + store.dispatch(setSearchResults(searchResultsObj)); store.dispatch(setSearchDetails(searchDetailsObj)); - //store.dispatch(setSearch(query.q)); + store.dispatch(setDocumentDetails(searchDocumentResultsObj)); + store.dispatch(setDocumentHistory(searchDocumentHistoryObj)); } ); @@ -121,6 +136,51 @@ const getSearchDetails = (token, searchResultsObj) => { return Promise.all(detailsArr); }; +const getDocumentDetails = (token, searchResultsObj) => { + //console.log(searchResultsObj); + + let detailsArr = []; + //console.log("search results", searchResultsObj); + searchResultsObj = searchResultsObj.value; + const detailsObj = searchResultsObj.map((searchDetail, index) => { + if (searchDetail.pinswg_appealcasetype == null) { + console.log(searchDetail.incidentid); + } else { + detailsArr.push( + getSearchDocumentDetails(token, searchDetail.incidentid) + ); + } + }); + //console.log(detailsArr); + return Promise.all(detailsArr); +}; + +const getDocumentHistory = (token, searchDocumentDetailsObj) => { + //console.log(searchResultsObj); + + let historyArr = []; + //console.log("search results", searchDocumentDetailsObj); + searchDocumentDetailsObj = searchDocumentDetailsObj[0].value; + + //console.log(searchDocumentDetailsObj); + const detailsObj = searchDocumentDetailsObj.map((historyDetail, index) => { + //console.log(historyDetail); + if (historyDetail.pinswg_publishtoweb != true) { + console.log(historyDetail.pinswg_documentid); + } else { + // console.log( + // "history detail documentid:", + // historyDetail.pinswg_documentid + // ); + historyArr.push( + getSearchDocumentHistory(token, historyDetail.pinswg_documentid) + ); + } + }); + console.log(historyArr); + return Promise.all(historyArr); +}; + const mapStateToProps = (state) => { return { currentView: state.currentView, diff --git a/pages/case.js b/pages/case.js index 11120215..7bc70e5c 100644 --- a/pages/case.js +++ b/pages/case.js @@ -48,6 +48,12 @@ const Home = (props) => { searchDetailsObj={ props.searchResultsObj.searchDetailsObj } + documentDetailsObj={ + props.searchResultsObj.documentDetailsObj + } + documentHistoryObj={ + props.searchResultsObj.documentHistoryObj + } myRepresentations={ props.myRepresentations.myRepresentations } @@ -61,6 +67,7 @@ const Home = (props) => { currentType={ props.currentView.caseReference.currentType } + incidentid={props.currentView.caseReference.incidentid} />
diff --git a/pages/searchresults.js b/pages/searchresults.js index b2b3dd3c..7b2757d8 100644 --- a/pages/searchresults.js +++ b/pages/searchresults.js @@ -20,9 +20,17 @@ import { setSearch, getSearchObj } from "../store/search/action"; import { setSearchResults, setSearchDetails, + setDocumentDetails, + setDocumentHistory, getSearchResultsObj, } from "../store/searchOutput/action"; -import { getBasicSearch, getBasicSearchDetails, getSASToken } from "../actions"; +import { + getBasicSearch, + getBasicSearchDetails, + getSearchDocumentDetails, + getSearchDocumentHistory, + getSASToken, +} from "../actions"; const Home = (props) => { const { footerLinks, pages } = props; @@ -71,9 +79,22 @@ export const getServerSideProps = wrapper.getServerSideProps( token, searchResultsObj ); - //console.log(searchDetailsObj); + + const searchDocumentResultsObj = await getDocumentDetails( + token, + searchResultsObj + ); + + const searchDocumentHistoryObj = await getDocumentHistory( + token, + searchDocumentResultsObj + ); + console.log(searchDocumentHistoryObj); + store.dispatch(setSearchResults(searchResultsObj)); store.dispatch(setSearchDetails(searchDetailsObj)); + store.dispatch(setDocumentDetails(searchDocumentResultsObj)); + store.dispatch(setDocumentHistory(searchDocumentHistoryObj)); store.dispatch(setSearch(query.q)); } ); @@ -91,7 +112,7 @@ const getSearchDetails = (token, searchResultsObj) => { //console.log(searchResultsObj); let detailsArr = []; - console.log("search results", searchResultsObj); + //console.log("search results", searchResultsObj); searchResultsObj = searchResultsObj.value; const detailsObj = searchResultsObj.map((searchDetail, index) => { if (searchDetail.pinswg_appealcasetype == null) { @@ -118,6 +139,51 @@ const getSearchDetails = (token, searchResultsObj) => { return Promise.all(detailsArr); }; +const getDocumentDetails = (token, searchResultsObj) => { + //console.log(searchResultsObj); + + let detailsArr = []; + //console.log("search results", searchResultsObj); + searchResultsObj = searchResultsObj.value; + const detailsObj = searchResultsObj.map((searchDetail, index) => { + if (searchDetail.pinswg_appealcasetype == null) { + console.log(searchDetail.incidentid); + } else { + detailsArr.push( + getSearchDocumentDetails(token, searchDetail.incidentid) + ); + } + }); + //console.log(detailsArr); + return Promise.all(detailsArr); +}; + +const getDocumentHistory = (token, searchDocumentDetailsObj) => { + //console.log(searchResultsObj); + + let historyArr = []; + //console.log("search results", searchDocumentDetailsObj); + searchDocumentDetailsObj = searchDocumentDetailsObj[0].value; + + //console.log(searchDocumentDetailsObj); + const detailsObj = searchDocumentDetailsObj.map((historyDetail, index) => { + //console.log(historyDetail); + if (historyDetail.pinswg_publishtoweb != true) { + console.log(historyDetail.pinswg_documentid); + } else { + // console.log( + // "history detail documentid:", + // historyDetail.pinswg_documentid + // ); + historyArr.push( + getSearchDocumentHistory(token, historyDetail.pinswg_documentid) + ); + } + }); + console.log(historyArr); + return Promise.all(historyArr); +}; + const mapStateToProps = (state) => { return { currentView: state.currentView, diff --git a/store/searchOutput/action.js b/store/searchOutput/action.js index d357357e..5b2ee845 100644 --- a/store/searchOutput/action.js +++ b/store/searchOutput/action.js @@ -3,6 +3,8 @@ export const searchResultsActionTypes = { SETSEARCHRESULTS: "SETSEARCHRESULTS", UPDATESEARCHRESULTS: "UPDATESEARCHRESULTS", SETSEARCHDETAILS: "SETSEARCHDETAILS", + SETDOCUMENTDETAILS: "SETDOCUMENTDETAILS", + SETDOCUMENTHISTORY: "SETDOCUMENTHISTORY", }; export const getSearchResultshObj = () => (dispatch) => { @@ -24,3 +26,16 @@ export const setSearchDetails = (searchDetails) => (dispatch) => { searchDetailsObj: searchDetails, }); }; +export const setDocumentDetails = (documentDetails) => (dispatch) => { + return dispatch({ + type: searchResultsActionTypes.SETDOCUMENTDETAILS, + documentDetailsObj: documentDetails, + }); +}; + +export const setDocumentHistory = (documentHistory) => (dispatch) => { + return dispatch({ + type: searchResultsActionTypes.SETDOCUMENTHISTORY, + documentHistoryObj: documentHistory, + }); +}; diff --git a/store/searchOutput/reducer.js b/store/searchOutput/reducer.js index 7f66cbbe..42e705af 100644 --- a/store/searchOutput/reducer.js +++ b/store/searchOutput/reducer.js @@ -3,6 +3,8 @@ import { searchResultsActionTypes } from "./action"; const searchResultsInitialState = { searchResultsObj: {}, searchDetailsObj: {}, + documentDetailsObj: {}, + documentHistoryObj: {}, }; export default function reducer(state = searchResultsInitialState, action) { @@ -17,6 +19,16 @@ export default function reducer(state = searchResultsInitialState, action) { ...state, searchDetailsObj: action.searchDetailsObj, }; + case searchResultsActionTypes.SETDOCUMENTDETAILS: + return { + ...state, + documentDetailsObj: action.documentDetailsObj, + }; + case searchResultsActionTypes.SETDOCUMENTHISTORY: + return { + ...state, + documentHistoryObj: action.documentHistoryObj, + }; default: return state; } From 27915a523decdccb470c21c2c72802a565368a7d Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Mon, 27 Sep 2021 16:46:39 +0100 Subject: [PATCH 2/2] updated the documents query and display --- actions/index.js | 32 +- components/breadcrumbs.js | 1039 ++++++++++++++-------------- components/case/documents.js | 120 +++- components/case/summary.js | 113 ++- components/search/searchresults.js | 6 +- data/lookuptranslations.json | 5 + pages/searchresults.js | 22 +- 7 files changed, 731 insertions(+), 606 deletions(-) diff --git a/actions/index.js b/actions/index.js index 76916c5a..bffe969d 100644 --- a/actions/index.js +++ b/actions/index.js @@ -143,7 +143,7 @@ export const getBasicSearch = (token, searchString) => { return axios .get( WEBAPI_URL + - "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=contains(title, '" + + "incidents?$select=_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=contains(title, '" + searchString + "') and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true&$top=201", azureHeaders(token) @@ -265,6 +265,36 @@ export const getSearchDocumentHistory = (token, documentID) => { }); }; +export const getSearchDocumentDetails1 = (incidentID) => { + var token = getSASToken(); + return axios + .get( + "/api/proxy/pinswg_documents?$count=true&$filter=_pinswg_documentids_value eq " + + incidentID + + " and pinswg_publishtoweb eq true&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference", + azureHeaders(token) + ) + .then((res) => res.data) + .catch((error) => { + console.log("thiserror", error); + }); +}; + +export const getSearchDocumentHistory1 = (documentID) => { + var token = getSASToken(); + return axios + .get( + "/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " + + documentID, + azureHeaders(token) + ) + .then((res) => { + return res.data; + }) + .catch((error) => { + console.log("thiserror", error); + }); +}; export const getBasicDNSSearchDetails = (token, appealType, caseReference) => { return axios .get( diff --git a/components/breadcrumbs.js b/components/breadcrumbs.js index b9353e71..9f950217 100644 --- a/components/breadcrumbs.js +++ b/components/breadcrumbs.js @@ -1,8 +1,10 @@ import Link from "next/link"; import jsonpath from "jsonpath"; import _ from "lodash"; +import { useState } from "react"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; +import LoadingOverlay from "react-loading-overlay"; const Breadcrumbs = (props) => { const { courseContent, slug, currentView } = props; @@ -36,510 +38,541 @@ const Breadcrumbs = (props) => { } } - return ( - + let spinnerState = () => { + showSpinnerState == true + ? setShowSpinnerState(false) + : setShowSpinnerState(true); + }; + return ( + <> + + + ); }; export default Breadcrumbs; diff --git a/components/case/documents.js b/components/case/documents.js index b72cd073..d79f4962 100644 --- a/components/case/documents.js +++ b/components/case/documents.js @@ -2,10 +2,28 @@ import Link from "next/link"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; import jsonpath from "jsonpath"; +import { useState, useEffect, useRef } from "react"; +import { useDispatch, useSelector, shallowEqual, connect } from "react-redux"; + +import { + getBasicSearch, + getBasicSearchDetails, + getSearchDocumentDetails1, + getSearchDocumentHistory1, + getSASToken, +} from "../../actions"; + +import { + setSearchResults, + setSearchDetails, + setDocumentDetails, + setDocumentHistory, + getSearchResultsObj, +} from "../../store/searchOutput/action"; const DocumentDetails = (props) => { let { t } = useTranslation(); - + const firstRender = useRef(false); const { incidentid, caseReference, @@ -20,10 +38,11 @@ const DocumentDetails = (props) => { var documentDetailsArr = documentDetailsObj || []; - console.log(documentDetailsObj); - console.log(documentDetailsArr); - const DocumentView = (documentDetailsArr) => { + console.log(documentDetailsArr); + + documentDetailsArr = documentDetailsArr.value; + return (
@@ -41,15 +60,14 @@ const DocumentDetails = (props) => {
- {documentDetailsArr.map((item, key) => { - console.log(key); + {documentDetailsArr.map((item) => { let detailsObj = jsonpath.query( - documentDetailsObj[key], - "$..value[?(@._pinswg_documentids_value=='" + + item, + "$..[?(@._pinswg_documentids_value=='" + incidentid + "')]" ); - detailsObj = detailsObj[0]; + detailsObj = item; if (typeof detailsObj != "undefined") { var documentHistoryArr = documentHistoryObj || []; @@ -60,7 +78,9 @@ const DocumentDetails = (props) => { detailsObj.pinswg_documentid + "')]" ); - return ( + + historyObj = historyObj[0]; + return !_.isEmpty(historyObj) ? (
{ )} : - {_.has(historyObj[key], [ + {_.has(historyObj, [ "_pinswg_documentid_value@OData.Community.Display.V1.FormattedValue", ]) - ? historyObj[key][ + ? historyObj[ "_pinswg_documentid_value@OData.Community.Display.V1.FormattedValue" ] : ""} @@ -103,10 +123,10 @@ const DocumentDetails = (props) => { : - {_.has(historyObj[key], [ + {_.has(historyObj, [ "pinswg_publisheddate@OData.Community.Display.V1.FormattedValue", ]) - ? historyObj[key][ + ? historyObj[ "pinswg_publisheddate@OData.Community.Display.V1.FormattedValue" ] : ""} @@ -118,6 +138,8 @@ const DocumentDetails = (props) => { 92
+ ) : ( + "" ); }); } @@ -126,20 +148,63 @@ const DocumentDetails = (props) => { ); }; + useEffect(() => { + const docDetailsObj = async () => { + let docObj = await getSearchDocumentDetails1(incidentid) + .then((data) => { + props.setDocumentDetails(data); + return data; + }) + .then((data) => { + let historyObj = getDocumentHistory(data.value).then( + (result) => { + props.setDocumentHistory(result); + return result; + } + ); + + return data; + }); + + return docObj; + }; + + const getDocumentHistory = async (searchDocumentDetailsObj) => { + let historyArr = []; + searchDocumentDetailsObj = searchDocumentDetailsObj; + + const detailsObj = searchDocumentDetailsObj.map( + (historyDetail, index) => { + if (historyDetail.pinswg_publishtoweb != true) { + console.log(historyDetail.pinswg_documentid); + } else { + historyArr.push( + getSearchDocumentHistory1( + historyDetail.pinswg_documentid + ) + ); + } + } + ); + return Promise.all(historyArr); + }; + + const searchDocumentResultsObj = docDetailsObj(); + }, []); + return (

Documents

- {console.log(documentDetailsObj)} - {documentDetailsArr.length > 0 ? ( - DocumentView(documentDetailsArr) - ) : ( + {_.isEmpty(documentHistoryObj) ? (

There are no documents for this appeal

+ ) : ( + DocumentView(documentDetailsArr) )}
@@ -147,4 +212,21 @@ const DocumentDetails = (props) => { ); }; -export default DocumentDetails; +const mapStateToProps = (state) => { + return { + ...state, + }; +}; + +const mapDispatchToProps = (dispatch) => { + return { + setDocumentDetails: (detailsObj) => { + dispatch(setDocumentDetails(detailsObj)); + }, + setDocumentHistory: (historyObj) => { + dispatch(setDocumentHistory(historyObj)); + }, + }; +}; + +export default connect(mapStateToProps, mapDispatchToProps)(DocumentDetails); diff --git a/components/case/summary.js b/components/case/summary.js index f3956b31..5ad6d5c5 100644 --- a/components/case/summary.js +++ b/components/case/summary.js @@ -210,31 +210,16 @@ const CaseSummary = (props) => { ? jsonpath.query( transLookup, '$..[?(@.value=="' + - detailsObj[ + casesObj[ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" ] + '")].value_cy' ) - : detailsObj[ + : casesObj[ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" ] || ""}
- {/*
-
- {t( - "case:summary-case-summary-label" - )} -
-
- {_.has( - detailsObj, - "pinswg_casedescription" - ) - ? detailsObj.pinswg_casedescription - : ""} -
-
*/}
{t( @@ -246,10 +231,12 @@ const CaseSummary = (props) => { {/* {casesObj.caseDetails.caseOfficer || ""} */} {_.has( - detailsObj, - "pinswg_casedescription" + casesObj, + "_ownerid_value" ) - ? detailsObj.pinswg_casedescription + ? casesObj[ + "_ownerid_value@OData.Community.Display.V1.FormattedValue" + ] : ""}
@@ -377,11 +364,11 @@ const CaseSummary = (props) => {
{_.has( detailsObj, - "pinswg_startdate@OData.Community.Display.V1.FormattedValue" + "pinswg_startdate" ) - ? detailsObj[ - "pinswg_startdate@OData.Community.Display.V1.FormattedValue" - ] + ? formatDates( + detailsObj.pinswg_startdate + ) : t( "case:summary-no-date-entered-label" )} @@ -397,11 +384,11 @@ const CaseSummary = (props) => {
{_.has( detailsObj, - "pinswg_questionnaireduedate@OData.Community.Display.V1.FormattedValue" + "pinswg_questionnaireduedate" ) - ? detailsObj[ - "pinswg_questionnaireduedate@OData.Community.Display.V1.FormattedValue" - ] + ? formatDates( + detailsObj.pinswg_questionnaireduedate + ) : t( "case:summary-no-date-entered-label" )} @@ -417,11 +404,11 @@ const CaseSummary = (props) => {
{_.has( detailsObj, - "pinswg_statementduedate@OData.Community.Display.V1.FormattedValue" + "pinswg_statementduedate" ) - ? detailsObj[ - "pinswg_statementduedate@OData.Community.Display.V1.FormattedValue" - ] + ? formatDates( + detailsObj.pinswg_statementduedate + ) : t( "case:summary-no-date-entered-label" )} @@ -437,11 +424,11 @@ const CaseSummary = (props) => {
{_.has( detailsObj, - "pinswg_otherpartiesstatement@OData.Community.Display.V1.FormattedValue" + "pinswg_otherpartiesstatement" ) - ? detailsObj[ - "pinswg_otherpartiesstatement@OData.Community.Display.V1.FormattedValue" - ] + ? formatDates( + detailsObj.pinswg_otherpartiesstatement + ) : t( "case:summary-no-date-entered-label" )} @@ -457,37 +444,16 @@ const CaseSummary = (props) => {
{_.has( detailsObj, - "pinswg_finalcommentsduedate@OData.Community.Display.V1.FormattedValue" + "pinswg_finalcommentsduedate" ) - ? detailsObj[ - "pinswg_finalcommentsduedate@OData.Community.Display.V1.FormattedValue" - ] + ? formatDates( + detailsObj.pinswg_finalcommentsduedate + ) : t( "case:summary-no-date-entered-label" )}
- -
-
- {t( - "case:summary-inquiry-evidence-date-label" - )} -
-
- {_.has( - detailsObj, - "pinswg_finalcommentsduedate@OData.Community.Display.V1.FormattedValue" - ) - ? detailsObj[ - "pinswg_finalcommentsduedate@OData.Community.Display.V1.FormattedValue" - ] - : t( - "case:summary-no-date-entered-label" - )} -
-
-
{t( @@ -497,11 +463,11 @@ const CaseSummary = (props) => {
{_.has( detailsObj, - "pinswg_dateeventrequested@OData.Community.Display.V1.FormattedValue" + "pinswg_dateeventrequested" ) - ? detailsObj[ - "pinswg_dateeventrequested@OData.Community.Display.V1.FormattedValue" - ] + ? formatDates( + detailsObj.pinswg_dateeventrequested + ) : t( "case:summary-no-date-entered-label" )} @@ -517,11 +483,11 @@ const CaseSummary = (props) => {
{_.has( detailsObj, - "pinswg_dateoflpadecision@OData.Community.Display.V1.FormattedValue" + "pinswg_dateoflpadecision" ) - ? detailsObj[ - "pinswg_dateoflpadecision@OData.Community.Display.V1.FormattedValue" - ] + ? formatDates( + detailsObj.pinswg_dateoflpadecision + ) : t( "case:summary-no-date-entered-label" )} @@ -582,6 +548,15 @@ const CaseSummary = (props) => { : setShowSpinnerState(true); }; + function formatDates(dateObj) { + var dateObj = new Date(dateObj); + var dd = String(dateObj.getDate()).padStart(2, "0"); + var mm = String(dateObj.getMonth() + 1).padStart(2, "0"); //January is 0! + var yyyy = dateObj.getFullYear(); + + return dd + "/" + mm + "/" + yyyy; + } + return ( <> {showDetailsBlock} diff --git a/components/search/searchresults.js b/components/search/searchresults.js index c283d830..af6ceeb1 100644 --- a/components/search/searchresults.js +++ b/components/search/searchresults.js @@ -120,19 +120,19 @@ const SearchResults = (props) => { {t("search:searchresults-authority-label")}: {_.has(item, [ - "_customerid_value@OData.Community.Display.V1.FormattedValue", + "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue", ]) ? router.locale == "cy" ? jsonpath.query( transLookup, '$..[?(@.value=="' + item[ - "_customerid_value@OData.Community.Display.V1.FormattedValue" + "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" ] + '")].value_cy' ) : item[ - "_customerid_value@OData.Community.Display.V1.FormattedValue" + "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" ] || "N/A" : ""}
diff --git a/data/lookuptranslations.json b/data/lookuptranslations.json index b8c4ed43..c5a76e08 100644 --- a/data/lookuptranslations.json +++ b/data/lookuptranslations.json @@ -291,6 +291,11 @@ "value_cy": "Cyngor Bwrdeistref Sirol Rhondda Cynon Taf", "pinswg_lpa": 0 }, + { + "value": "Rhondda Cynon Taf CBC", + "value_cy": "Cyngor Bwrdeistref Sirol Rhondda Cynon Taf", + "pinswg_lpa": 0 + }, { "value": "Swansea Council", "value_cy": "Cyngor a Dinas Abertawe", diff --git a/pages/searchresults.js b/pages/searchresults.js index 7b2757d8..f465e4fa 100644 --- a/pages/searchresults.js +++ b/pages/searchresults.js @@ -80,21 +80,21 @@ export const getServerSideProps = wrapper.getServerSideProps( searchResultsObj ); - const searchDocumentResultsObj = await getDocumentDetails( - token, - searchResultsObj - ); + // const searchDocumentResultsObj = await getDocumentDetails( + // token, + // searchResultsObj + // ); - const searchDocumentHistoryObj = await getDocumentHistory( - token, - searchDocumentResultsObj - ); - console.log(searchDocumentHistoryObj); + // const searchDocumentHistoryObj = await getDocumentHistory( + // token, + // searchDocumentResultsObj + // ); + // console.log(searchDocumentHistoryObj); store.dispatch(setSearchResults(searchResultsObj)); store.dispatch(setSearchDetails(searchDetailsObj)); - store.dispatch(setDocumentDetails(searchDocumentResultsObj)); - store.dispatch(setDocumentHistory(searchDocumentHistoryObj)); + //store.dispatch(setDocumentDetails(searchDocumentResultsObj)); + //store.dispatch(setDocumentHistory(searchDocumentHistoryObj)); store.dispatch(setSearch(query.q)); } );