import { JSONPath as jsonpath } from "jsonpath-plus"; import _ from "lodash"; import useTranslation from "next-translate/useTranslation"; import Link from "next/link"; import { useRouter } from "next/router"; import { parseCookies } from "nookies"; import { connect } from "react-redux"; import { deleteAwaitingSubmissions, deleteWatchedCases, getAwaitingSubmissionProxy, getPortalModuleDetailsProxy, getWatchedCasesProxy, } from "../../actions"; import { getFormCollectionByID, getDetailsProxy } from "../../components/utils"; import transLookup from "../../data/lookuptranslations.json"; import { setAwaitingSubmission, setAwaitingSubmissionDetails, } from "../../store/awaitingSubmission/action"; import { setCurrentReference } from "../../store/currentView/action"; import { setSearchDetails, setSearchResults, } from "../../store/searchOutput/action"; import { setWatchedCases, setWatchedCasesDetails, } from "../../store/watchedCases/action"; const TopThree = (props) => { let { t } = useTranslation(); const { currentView, showTopThree, showDetails, setCurrentReference, topThreeType, setWatchedCases, setWatchedCasesDetails, setAwaitingSubmission, setAwaitingSubmissionDetails, setSearchResults, setSearchDetails, showLoginCheck, } = props; const router = useRouter(); const { locale } = router; let topthreeRow = []; let showTopThreeArr; showTopThreeArr = props.myReps ? showTopThree : showTopThree.value; Object.keys(showTopThreeArr).map((key, index) => { let createdDate = parseInt(showTopThreeArr[key].createdon); showTopThreeArr[key].createdDate = createdDate; }); showTopThreeArr.sort(function compare(a, b) { var dateA = new Date(a.createdDate); var dateB = new Date(b.createdDate); return dateB - dateA; }); const raisedDate = (datePart) => { var dateObj = new Date(datePart); return dateObj.toLocaleString(); }; const deleteItem = (caseID, topThreeType) => { let cookies = parseCookies(); //console.log("sssss", caseID, topThreeType); topThreeType == "watchedCases" && deleteWatchedCases(caseID) .then((data) => data) .then(() => { getWatchedCasesProxy(cookies.pinsUser).then((data) => { setWatchedCases(data), getDetailsProxy(data, "myWatchedCases").then( (data) => { setWatchedCasesDetails(data); } ); }); }); topThreeType == "awaitingSubmission" && deleteAwaitingSubmissions(caseID) .then((data) => { return data; }) .then(() => { getAwaitingSubmissionProxy(cookies.pinsUser).then( (data) => { setAwaitingSubmission(data), getDetailsProxy( data, "awaitingSubmission" ).then((data) => { //console.log( // "submission get details:", // data // ); setAwaitingSubmissionDetails(data); }); } ); }); }; const getIncidentId = (topThreeType, objArr) => { switch (topThreeType) { case "myCases": return objArr.incidentid; break; case "watchedCases": return objArr._pinswg_watchedcase_value; break; case "myRepresentations": return objArr.ticketnumber; break; case "awaitingSubmission": return objArr.ticketnumber; break; default: // code block } }; let topThreeOnlyArr = showTopThreeArr.slice(0, 3); Object.keys(topThreeOnlyArr).map((key, index) => { topthreeRow.push(