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));
}
);