updated cookie manger added cookie policy
This commit is contained in:
@@ -7,35 +7,249 @@ import jsonpath from "jsonpath";
|
||||
import _ from "lodash";
|
||||
import transLookup from "../../data/lookuptranslations.json";
|
||||
import LoadingOverlay from "react-loading-overlay";
|
||||
import { getRepresentations } from "../../actions";
|
||||
import { setRepresentations } from "../../store/searchOutput/action";
|
||||
import PaginationControl from "./pagination";
|
||||
|
||||
const RepresentationList = (props) => {
|
||||
const { incidentid, representationsObj, setRepresentations } = props;
|
||||
let { t } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
const [showSpinnerState, setShowSpinnerState] = useState(false);
|
||||
// const [showSpinnerState, setShowSpinnerState] = useState(false);
|
||||
|
||||
let spinnerState = () => {
|
||||
showSpinnerState == true
|
||||
? setShowSpinnerState(false)
|
||||
: setShowSpinnerState(true);
|
||||
// let spinnerState = () => {
|
||||
// showSpinnerState == true
|
||||
// ? setShowSpinnerState(false)
|
||||
// : setShowSpinnerState(true);
|
||||
// };
|
||||
|
||||
var representationsArr = representationsObj || [];
|
||||
|
||||
const RepresentationsView = (representationsArr) => {
|
||||
//console.log(documentDetailsArr);
|
||||
|
||||
representationsArr = representationsArr.value;
|
||||
return (
|
||||
<>
|
||||
<p>
|
||||
{representationsObj["@odata.count"] > 1
|
||||
? t("case:documents-count-label-1")
|
||||
: t("case:documents-count-label-1a")}{" "}
|
||||
{representationsObj["@odata.count"]}{" "}
|
||||
{
|
||||
representationsObj["@odata.count"] > 1
|
||||
? "representations " //t("case:documents-count-label-2")
|
||||
: "representations " //t("case:documents-count-label-2a")
|
||||
}
|
||||
</p>
|
||||
<dl className="documentList govuk-summary-list govuk-!-margin-bottom-9 results">
|
||||
<div className="govuk-summary-list__row results-headings">
|
||||
<dd className="govuk-summary-list__key govuk-!-font-size-16 ">
|
||||
{
|
||||
"Type of representation" //t("case:documents-name-label")
|
||||
}
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__key govuk-!-font-size-16">
|
||||
{t("case:documents-doc-type-label")}
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__key govuk-!-font-size-16">
|
||||
{t("case:documents-date-published-label")}
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
{representationsArr.map((item, key) => {
|
||||
let detailsObj = jsonpath.query(
|
||||
item,
|
||||
"$..[?(@.pinswg_representationsid=='" +
|
||||
incidentid +
|
||||
"')]"
|
||||
);
|
||||
detailsObj = item;
|
||||
|
||||
console.log(detailsObj);
|
||||
|
||||
return (
|
||||
<div className="govuk-summary-list__row" key={key}>
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-16 ">
|
||||
<a
|
||||
href={
|
||||
"/api/proxy/documents/download/" +
|
||||
detailsObj.pinswg_isharedocumentreference
|
||||
}
|
||||
>
|
||||
<span className="results-visually-hidden">
|
||||
{t("case:documents-name-label")}:
|
||||
</span>
|
||||
{
|
||||
detailsObj[
|
||||
"pinswg_whatkind@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
}
|
||||
</a>
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-16">
|
||||
<span className="results-visually-hidden">
|
||||
{t("case:documents-doc-type-label")}:
|
||||
</span>
|
||||
|
||||
{router.locale == "cy"
|
||||
? jsonpath.query(
|
||||
transLookup,
|
||||
'$..[?(@.value=="' +
|
||||
detailsObj[
|
||||
"pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue"
|
||||
] +
|
||||
'")].value_cy'
|
||||
)
|
||||
: detailsObj[
|
||||
"pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue"
|
||||
] ||
|
||||
t(
|
||||
"case:summary-no-date-entered-label"
|
||||
)}
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-16">
|
||||
<span className="results-visually-hidden">
|
||||
{t(
|
||||
"case:documents-date-published-label"
|
||||
)}
|
||||
:
|
||||
</span>
|
||||
|
||||
{formatDates(
|
||||
detailsObj[
|
||||
"createdon@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
)}
|
||||
</dd>
|
||||
{/* <dd className="govuk-summary-list__value govuk-!-font-size-16">
|
||||
<span className="results-visually-hidden">
|
||||
{t("case:documents-size-label")}:
|
||||
</span>
|
||||
92
|
||||
</dd> */}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</dl>
|
||||
{/* <PaginationControl
|
||||
currentPage={currentPage}
|
||||
searchResultsObj={documentDetailsObj}
|
||||
// spinnerState={spinnerState}
|
||||
getDocumentResults={getDocumentResults}
|
||||
/> */}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const representationDetailsObj = async () => {
|
||||
let docObj = await getRepresentations(incidentid).then((data) => {
|
||||
console.log(data);
|
||||
setRepresentationSearchState(true);
|
||||
setRepresentations(data);
|
||||
return data;
|
||||
});
|
||||
|
||||
return docObj;
|
||||
};
|
||||
const representationResultsObj = representationDetailsObj();
|
||||
}, [incidentid, setRepresentations]);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
const pagesCount = Math.ceil(representationsObj["@odata.count"] / 10);
|
||||
|
||||
let currentPage = 0;
|
||||
|
||||
currentPage = decodeURI(representationsObj["@odata.nextLink"]).split(
|
||||
"skiptoken="
|
||||
)[1];
|
||||
currentPage =
|
||||
typeof currentPage != "undefined"
|
||||
? parseInt(
|
||||
decodeURI(currentPage)
|
||||
.split('pagenumber="')[1]
|
||||
.slice(
|
||||
0,
|
||||
decodeURI(currentPage)
|
||||
.split('pagenumber="')[1]
|
||||
.indexOf('"')
|
||||
) - 1
|
||||
)
|
||||
: pagesCount;
|
||||
|
||||
//const [showSpinnerState, setShowSpinnerState] = useState(false);
|
||||
|
||||
// let spinnerState = () => {
|
||||
// showSpinnerState == true
|
||||
// ? setShowSpinnerState(false)
|
||||
// : setShowSpinnerState(true);
|
||||
// };
|
||||
|
||||
const [showReperesentationSearchState, setRepresentationSearchState] =
|
||||
useState(false);
|
||||
|
||||
let representationSearchState = () => {
|
||||
showReperesentationSearchState == true
|
||||
? setRepresentationSearchState(false)
|
||||
: setRepresentationSearchState(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<div className="govuk-grid-row">
|
||||
<div className="card">
|
||||
<div className="govuk-grid-row card-body">
|
||||
<div className="govuk-grid-column-full">
|
||||
<h2>Representations</h2>
|
||||
{_.isEmpty(representationsObj) ? (
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-two-thirds">
|
||||
<h3>
|
||||
{showReperesentationSearchState == false
|
||||
? "Checking for representations "
|
||||
: t(
|
||||
"case:documents-non-available-label"
|
||||
)}
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
RepresentationsView(representationsArr)
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<LoadingOverlay
|
||||
{/* <LoadingOverlay
|
||||
active={showSpinnerState}
|
||||
spinner
|
||||
text={t("common:spinner-searching")}
|
||||
/>
|
||||
/> */}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default RepresentationList;
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
...state,
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
setRepresentations: (representationObj) => {
|
||||
dispatch(setRepresentations(representationObj));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(RepresentationList);
|
||||
|
||||
Reference in New Issue
Block a user