Merged PR 477: updated the documents query and display
updated the documents query and display Related work items: #6248
This commit is contained in:
+31
-1
@@ -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(
|
||||
|
||||
+536
-503
File diff suppressed because it is too large
Load Diff
+101
-19
@@ -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 (
|
||||
<dl className="govuk-summary-list govuk-!-margin-bottom-9 results">
|
||||
<div className="govuk-summary-list__row results-headings">
|
||||
@@ -41,15 +60,14 @@ const DocumentDetails = (props) => {
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
{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) ? (
|
||||
<div
|
||||
className="govuk-summary-list__row"
|
||||
key={key}
|
||||
@@ -74,10 +94,10 @@ const DocumentDetails = (props) => {
|
||||
)}
|
||||
:
|
||||
</span>
|
||||
{_.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) => {
|
||||
:
|
||||
</span>
|
||||
|
||||
{_.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
|
||||
</dd>
|
||||
</div>
|
||||
) : (
|
||||
""
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -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 (
|
||||
<div>
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-full">
|
||||
<h2>Documents</h2>
|
||||
{console.log(documentDetailsObj)}
|
||||
{documentDetailsArr.length > 0 ? (
|
||||
DocumentView(documentDetailsArr)
|
||||
) : (
|
||||
{_.isEmpty(documentHistoryObj) ? (
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-two-thirds">
|
||||
<h3>There are no documents for this appeal</h3>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
DocumentView(documentDetailsArr)
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
@@ -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);
|
||||
|
||||
+44
-69
@@ -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"
|
||||
] || ""}
|
||||
</dd>
|
||||
</div>
|
||||
{/* <div className="govuk-summary-list__row">
|
||||
<dt className="govuk-summary-list__key">
|
||||
{t(
|
||||
"case:summary-case-summary-label"
|
||||
)}
|
||||
</dt>
|
||||
<dd className="govuk-summary-list__value">
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_casedescription"
|
||||
)
|
||||
? detailsObj.pinswg_casedescription
|
||||
: ""}
|
||||
</dd>
|
||||
</div> */}
|
||||
<div className="govuk-summary-list__row">
|
||||
<dt className="govuk-summary-list__key">
|
||||
{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"
|
||||
]
|
||||
: ""}
|
||||
</dd>
|
||||
</div>
|
||||
@@ -377,11 +364,11 @@ const CaseSummary = (props) => {
|
||||
<dd className="govuk-summary-list__value">
|
||||
{_.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) => {
|
||||
<dd className="govuk-summary-list__value">
|
||||
{_.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) => {
|
||||
<dd className="govuk-summary-list__value">
|
||||
{_.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) => {
|
||||
<dd className="govuk-summary-list__value">
|
||||
{_.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) => {
|
||||
<dd className="govuk-summary-list__value">
|
||||
{_.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"
|
||||
)}
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className="govuk-summary-list__row">
|
||||
<dt className="govuk-summary-list__key">
|
||||
{t(
|
||||
"case:summary-inquiry-evidence-date-label"
|
||||
)}
|
||||
</dt>
|
||||
<dd className="govuk-summary-list__value">
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_finalcommentsduedate@OData.Community.Display.V1.FormattedValue"
|
||||
)
|
||||
? detailsObj[
|
||||
"pinswg_finalcommentsduedate@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
: t(
|
||||
"case:summary-no-date-entered-label"
|
||||
)}
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div className="govuk-summary-list__row">
|
||||
<dt className="govuk-summary-list__key">
|
||||
{t(
|
||||
@@ -497,11 +463,11 @@ const CaseSummary = (props) => {
|
||||
<dd className="govuk-summary-list__value">
|
||||
{_.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) => {
|
||||
<dd className="govuk-summary-list__value">
|
||||
{_.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}
|
||||
|
||||
@@ -120,19 +120,19 @@ const SearchResults = (props) => {
|
||||
{t("search:searchresults-authority-label")}:
|
||||
</span>
|
||||
{_.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"
|
||||
: ""}
|
||||
</dd>
|
||||
|
||||
@@ -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",
|
||||
|
||||
+11
-11
@@ -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));
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user