logic to let child cases be shown in case details
This commit is contained in:
@@ -30,6 +30,7 @@ const CaseSummary = (props) => {
|
||||
searchResultsObj={props.searchResultsObj}
|
||||
searchDetailsObj={props.searchDetailsObj}
|
||||
searchString={props.searchString}
|
||||
incidentid={props.incidentid}
|
||||
/>
|
||||
<Documents
|
||||
incidentid={props.incidentid}
|
||||
|
||||
@@ -42,7 +42,7 @@ const DocumentDetails = (props) => {
|
||||
var documentDetailsArr = documentDetailsObj || [];
|
||||
|
||||
const DocumentView = (documentDetailsArr) => {
|
||||
console.log(documentDetailsArr);
|
||||
//console.log(documentDetailsArr);
|
||||
|
||||
documentDetailsArr = documentDetailsArr.value;
|
||||
|
||||
@@ -173,7 +173,7 @@ const DocumentDetails = (props) => {
|
||||
const docDetailsObj = async () => {
|
||||
let docObj = await getSearchDocumentDetails1(incidentid)
|
||||
.then((data) => {
|
||||
console.log(data);
|
||||
//console.log(data);
|
||||
setDocumentDetails(data);
|
||||
return data;
|
||||
})
|
||||
|
||||
+112
-18
@@ -1,18 +1,26 @@
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { useState } from "react";
|
||||
import { useState, useEffect, useRef } from "react";
|
||||
import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
|
||||
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";
|
||||
|
||||
import { getLinkedCases } from "../../actions";
|
||||
import {
|
||||
setCurrentLinkedCases,
|
||||
setCurrentReference,
|
||||
} from "../../store/currentView/action";
|
||||
|
||||
const CaseSummary = (props) => {
|
||||
let { t } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
const {
|
||||
incidentid,
|
||||
caseReference,
|
||||
myCases,
|
||||
myRepresentations,
|
||||
@@ -21,6 +29,9 @@ const CaseSummary = (props) => {
|
||||
searchResultsObj,
|
||||
searchDetailsObj,
|
||||
currentType,
|
||||
setCurrentLinkedCases,
|
||||
linkedCasesReference,
|
||||
setCurrentReference,
|
||||
} = props;
|
||||
|
||||
const noRepresentationLink = ["/case", "/dnsdetails"];
|
||||
@@ -322,28 +333,39 @@ const CaseSummary = (props) => {
|
||||
)}
|
||||
</dt>
|
||||
<dd className="govuk-summary-list__value">
|
||||
{_.has(detailsObj, [
|
||||
"pinswg_linkedstatus@OData.Community.Display.V1.FormattedValue",
|
||||
{_.has(casesObj, [
|
||||
"numberofchildincidents",
|
||||
])
|
||||
? detailsObj[
|
||||
"pinswg_linkedstatus@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
? casesObj.numberofchildincidents >
|
||||
0
|
||||
? t(
|
||||
"case:summary-case-link-status-linked"
|
||||
)
|
||||
: t(
|
||||
"case:summary-case-link-status-not-linked"
|
||||
)
|
||||
: t(
|
||||
"case:summary-case-link-status-not-linked"
|
||||
)}
|
||||
</dd>
|
||||
</div>
|
||||
<div className="govuk-summary-list__row">
|
||||
<dt className="govuk-summary-list__key">
|
||||
{t(
|
||||
"case:summary-linked-cases-label"
|
||||
)}
|
||||
</dt>
|
||||
<dd className="govuk-summary-list__value">
|
||||
{/* {casesObj.caseDetails.linkedCases ||
|
||||
""} */}
|
||||
</dd>
|
||||
</div>
|
||||
{casesObj.numberofchildincidents > 0 ? (
|
||||
<div className="govuk-summary-list__row">
|
||||
<dt className="govuk-summary-list__key">
|
||||
{t(
|
||||
"case:summary-linked-cases-label"
|
||||
)}
|
||||
</dt>
|
||||
<dd className="govuk-summary-list__value">
|
||||
{linkedCasesList(
|
||||
props.currentView
|
||||
.linkedCaseReferences
|
||||
)}
|
||||
</dd>
|
||||
</div>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
@@ -582,6 +604,20 @@ const CaseSummary = (props) => {
|
||||
</>
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const linkCaseObj = async () => {
|
||||
let docObj = await getLinkedCases(incidentid).then((data) => {
|
||||
console.log(data);
|
||||
setCurrentLinkedCases(data);
|
||||
return data;
|
||||
});
|
||||
|
||||
return linkCaseObj;
|
||||
};
|
||||
|
||||
const linkedCases = linkCaseObj();
|
||||
}, [incidentid, setCurrentLinkedCases]);
|
||||
|
||||
const [showSpinnerState, setShowSpinnerState] = useState(false);
|
||||
|
||||
let spinnerState = () => {
|
||||
@@ -599,6 +635,47 @@ const CaseSummary = (props) => {
|
||||
return dd + "/" + mm + "/" + yyyy;
|
||||
}
|
||||
|
||||
function linkedCasesList(linkedCasesReference) {
|
||||
console.log(linkedCasesReference);
|
||||
|
||||
linkedCasesReference = linkedCasesReference.value || [];
|
||||
|
||||
return (
|
||||
<>
|
||||
<ul className="govuk-list govuk-!-font-size-14">
|
||||
{linkedCasesReference.map((item, key) => {
|
||||
return (
|
||||
<li key={key}>
|
||||
<Link
|
||||
href={
|
||||
router.locale == "cy"
|
||||
? "/achos"
|
||||
: "/case"
|
||||
}
|
||||
>
|
||||
<a
|
||||
onClick={() => {
|
||||
setCurrentReference({
|
||||
"currentReference": item.title,
|
||||
"currentType":
|
||||
"searchResultsObj",
|
||||
"incidentid": item.incidentid,
|
||||
});
|
||||
}}
|
||||
className=""
|
||||
>
|
||||
{item.title}
|
||||
</a>
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
// console.log(item.incidentid, item.title);
|
||||
})}
|
||||
</ul>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{showDetailsBlock}
|
||||
@@ -611,4 +688,21 @@ const CaseSummary = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default CaseSummary;
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
...state,
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
setCurrentLinkedCases: (parentIncidentid) => {
|
||||
dispatch(setCurrentLinkedCases(parentIncidentid));
|
||||
},
|
||||
setCurrentReference: (currentReference) => {
|
||||
dispatch(setCurrentReference(currentReference));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(CaseSummary);
|
||||
|
||||
@@ -15,7 +15,7 @@ const CRMError = (props) => {
|
||||
? "LPAData"
|
||||
: "searchResultsObj";
|
||||
|
||||
console.log(errorSwitch);
|
||||
//console.log(errorSwitch);
|
||||
|
||||
return (
|
||||
<div className="govuk-grid-row">
|
||||
|
||||
@@ -17,7 +17,7 @@ export default function Search(props) {
|
||||
? true
|
||||
: false;
|
||||
|
||||
console.log("has an error", hasError);
|
||||
//console.log("has an error", hasError);
|
||||
|
||||
return (
|
||||
<main
|
||||
|
||||
@@ -243,7 +243,7 @@ let AdvancedSearch = (props) => {
|
||||
event.preventDefault();
|
||||
spinnerState();
|
||||
|
||||
console.log(values);
|
||||
//console.log(values);
|
||||
// var appTypeCollection = values.appealTypes.split(",")[1];
|
||||
|
||||
// appTypeCollection = getFormCollection(
|
||||
|
||||
@@ -17,7 +17,7 @@ export default function Search(props) {
|
||||
? true
|
||||
: false;
|
||||
|
||||
console.log("has an error", hasError);
|
||||
//console.log("has an error", hasError);
|
||||
|
||||
return (
|
||||
<main
|
||||
|
||||
Reference in New Issue
Block a user