diff --git a/actions/index.js b/actions/index.js index 9d01abf4..bffe969d 100644 --- a/actions/index.js +++ b/actions/index.js @@ -143,17 +143,17 @@ 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 &$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,65 @@ 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 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( @@ -311,64 +370,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 +394,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 +472,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/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.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..d79f4962 100644 --- a/components/case/documents.js +++ b/components/case/documents.js @@ -1,65 +1,232 @@ 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"; -export default function CaseSummary() { +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, + searchResultsObj, + searchDetailsObj, + documentDetailsObj, + documentHistoryObj, + } = props; const router = useRouter(); const { locale } = router; + + var documentDetailsArr = documentDetailsObj || []; + + const DocumentView = (documentDetailsArr) => { + console.log(documentDetailsArr); + + documentDetailsArr = documentDetailsArr.value; + + 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) => { + let detailsObj = jsonpath.query( + item, + "$..[?(@._pinswg_documentids_value=='" + + incidentid + + "')]" + ); + detailsObj = item; + + 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 + + "')]" + ); + + historyObj = historyObj[0]; + return !_.isEmpty(historyObj) ? ( +
+
+ + + + {t( + "case:documents-name-label" + )} + : + + {_.has(historyObj, [ + "_pinswg_documentid_value@OData.Community.Display.V1.FormattedValue", + ]) + ? historyObj[ + "_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, [ + "pinswg_publisheddate@OData.Community.Display.V1.FormattedValue", + ]) + ? historyObj[ + "pinswg_publisheddate@OData.Community.Display.V1.FormattedValue" + ] + : ""} +
+
+ + {t("case:documents-size-label")}: + + 92 +
+
+ ) : ( + "" + ); + }); + } + })} +
+ ); + }; + + 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

-
-
-
- {t("case:documents-name-label")} -
-
- {t("case:documents-doc-type-label")} -
-
- {t("case:documents-date-published-label")} -
-
- {t("case:documents-size-label")} -
+ {_.isEmpty(documentHistoryObj) ? ( +
+
+

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 -
-
-
+ ) : ( + DocumentView(documentDetailsArr) + )}
); -} +}; + +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 8979051d..5ad6d5c5 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,468 +55,517 @@ 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-summary-label" - )} -
-
- {_.has( - detailsObj, - "pinswg_casedescription" - ) - ? detailsObj.pinswg_casedescription - : ""} -
-
*/} -
-
- {t( - "case:summary-case-officer-label" - )} -
-
- {" "} - {/* {casesObj.caseDetails.caseOfficer || + { + spinnerState(); + router.back(); + }} + className="govuk-button govuk-button--secondary" + > + {t("case:summary-back-button-label")} + +
+
+
+
+
+
+
+
+

+ {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=="' + + casesObj[ + "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" + ] + + '")].value_cy' + ) + : casesObj[ + "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" + ] || ""} +
+
+
+
+ {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( + casesObj, + "_ownerid_value" + ) + ? casesObj[ + "_ownerid_value@OData.Community.Display.V1.FormattedValue" + ] + : ""} +
+
+
+
+ {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" + ) + ? formatDates( + detailsObj.pinswg_startdate + ) + : 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" + ) + ? formatDates( + detailsObj.pinswg_questionnaireduedate + ) + : 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" + ) + ? formatDates( + detailsObj.pinswg_statementduedate + ) + : 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" + ) + ? formatDates( + detailsObj.pinswg_otherpartiesstatement + ) + : 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" + ) + ? formatDates( + detailsObj.pinswg_finalcommentsduedate + ) + : t( + "case:summary-no-date-entered-label" + )} +
+
+
+
+ {t( + "case:summary-event-date-label" + )} +
+
+ {_.has( + detailsObj, + "pinswg_dateeventrequested" + ) + ? formatDates( + detailsObj.pinswg_dateeventrequested + ) + : 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-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" + ) + ? formatDates( + detailsObj.pinswg_dateoflpadecision + ) + : 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); + }; + + 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 f2066245..af6ceeb1 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, }); }} > @@ -119,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 27d6418f..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", @@ -343,5 +348,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} />