diff --git a/components/myportal/awaitingsubmission.js b/components/myportal/awaitingsubmission.js index ef5095df..12c4ee22 100644 --- a/components/myportal/awaitingsubmission.js +++ b/components/myportal/awaitingsubmission.js @@ -37,8 +37,8 @@ const AwaitingSubmission = (props) => { router.locale != "en" ? "/" + router.locale + - "/fymhorth/gweldpopeth" - : "/myportal/viewall" + "/fymhorth/gweldpopeth?key=awaitingSubmission" + : "/myportal/viewall?key=awaitingSubmission" } className="govuk-link--no-underline" onClick={() => { diff --git a/components/myportal/awaitingsubmissionfromblob.js b/components/myportal/awaitingsubmissionfromblob.js index 26baf861..33f9e6f4 100644 --- a/components/myportal/awaitingsubmissionfromblob.js +++ b/components/myportal/awaitingsubmissionfromblob.js @@ -354,8 +354,8 @@ const AwaitingSubmissionFromBlob = (props) => { router.locale != "en" ? "/" + router.locale + - "/fymhorth/gweldpopeth" - : "/myportal/viewall" + "/fymhorth/gweldpopeth?key=awaitingSubmissionDetails" + : "/myportal/viewall?key=awaitingSubmissionDetails" } className="govuk-link--no-underline" onClick={() => { diff --git a/components/myportal/mycases.js b/components/myportal/mycases.js index 97d09e4a..e8b3d19b 100644 --- a/components/myportal/mycases.js +++ b/components/myportal/mycases.js @@ -32,8 +32,8 @@ const MyCases = (props) => { router.locale != "en" ? "/" + router.locale + - "/fymhorth/gweldpopeth" - : "/myportal/viewall" + "/fymhorth/gweldpopeth?key=myCases" + : "/myportal/viewall?key=myCases" } className="govuk-link--no-underline" onClick={() => { diff --git a/components/myportal/myrepresentations.js b/components/myportal/myrepresentations.js index 54d2f555..17430582 100644 --- a/components/myportal/myrepresentations.js +++ b/components/myportal/myrepresentations.js @@ -37,8 +37,8 @@ const MyRepresentations = (props) => { router.locale != "en" ? "/" + router.locale + - "/fymhorth/gweldpopeth" - : "/myportal/viewall" + "/fymhorth/gweldpopeth?key=myRepresentations" + : "/myportal/viewall?key=myRepresentations" } className="govuk-link--no-underline" onClick={() => { diff --git a/components/myportal/myrepresentationsfromblob.js b/components/myportal/myrepresentationsfromblob.js index 4035c5fa..129cfd1e 100644 --- a/components/myportal/myrepresentationsfromblob.js +++ b/components/myportal/myrepresentationsfromblob.js @@ -36,8 +36,8 @@ const MyRepresentations = (props) => { router.locale != "en" ? "/" + router.locale + - "/fymhorth/gweldpopeth" - : "/myportal/viewall" + "/fymhorth/gweldpopeth?key=myRepresentations" + : "/myportal/viewall?key=myRepresentations" } className="govuk-link--no-underline" onClick={() => { diff --git a/components/myportal/mysubmittedrepresentations.js b/components/myportal/mysubmittedrepresentations.js index 8a6b2b0f..98d9bf0c 100644 --- a/components/myportal/mysubmittedrepresentations.js +++ b/components/myportal/mysubmittedrepresentations.js @@ -43,8 +43,8 @@ const MySubmittedReps = (props) => { router.locale != "en" ? "/" + router.locale + - "/fymhorth/gweldpopeth" - : "/myportal/viewall" + "/fymhorth/gweldpopeth?key=mySubmittedReps" + : "/myportal/viewall?key=mySubmittedReps" } className="govuk-link--no-underline" onClick={() => { diff --git a/components/myportal/viewall.js b/components/myportal/viewall.js index 11cc24c2..ae772292 100644 --- a/components/myportal/viewall.js +++ b/components/myportal/viewall.js @@ -76,19 +76,23 @@ const ViewAllResults = (props) => { return dateObj.toLocaleString(); }; - let currentView = props.currentView.currentView; - //console.log("currentView.viewKey:", typeof currentView.viewKey); + let viewKeyFromUrl = router.query.key; - // typeof currentView.viewKey == "undefined" + let currentView = props.currentView.currentView; + //console.log("currentViewKey:", typeof currentViewKey); + + // typeof currentViewKey == "undefined" // ? console.log("no currentview") // : console.log("has currentview"); + let currentViewKey = currentView.viewKey || viewKeyFromUrl; + var resultsArr = - currentView.viewKey == "awaitingSubmissionDetails" + currentViewKey == "awaitingSubmissionDetails" ? props["awaitingSubmission"].awaitingSubmissionDetails.case - : currentView.viewKey == "mySubmittedReps" - ? props[currentView.viewKey][currentView.viewKey] - : props[currentView.viewKey][currentView.viewKey].value || []; + : currentViewKey == "mySubmittedReps" + ? props[currentViewKey][currentViewKey] + : props[currentViewKey][currentViewKey].value || []; const [orderByState, setOrderbyState] = useState("createdon"); const [fieldSortState, setfieldSortState] = useState("asc"); @@ -105,11 +109,11 @@ const ViewAllResults = (props) => { } var searchDetailsObj = - currentView.viewKey == "awaitingSubmissionDetails" + currentViewKey == "awaitingSubmissionDetails" ? props["awaitingSubmission"].awaitingSubmissionDetails.value - : currentView.viewKey == "myRepresentations" + : currentViewKey == "myRepresentations" ? props["myRepresentations"].myRepresentations.value - : props[currentView.viewKey][currentView.viewKey + "Details"] || []; + : props[currentViewKey][currentViewKey + "Details"] || []; let resultsRowArr = []; const buildResultsRowArr = () => { @@ -117,15 +121,13 @@ const ViewAllResults = (props) => { let detailsObj = jsonpath({ path: "$" + - (currentView.viewKey == "myRepresentations" - ? "" - : "..value") + + (currentViewKey == "myRepresentations" ? "" : "..value") + '[?(@ && @.pinswg_name=="' + - (currentView.viewKey == "awaitingSubmissionDetails" + (currentViewKey == "awaitingSubmissionDetails" ? item.title - : currentView.viewKey == "watchedCases" + : currentViewKey == "watchedCases" ? item.ticketnumber - : currentView.viewKey == "myRepresentations" + : currentViewKey == "myRepresentations" ? item.pinswg_name : item.pinswg_title) + '")]', @@ -137,7 +139,7 @@ const ViewAllResults = (props) => { //console.log(searchDetailsObj[key]); // searchDetailsObj[key] = - // currentView.viewKey == "myRepresentations" + // currentViewKey == "myRepresentations" // ? searchDetailsObj[key].value[0] // : searchDetailsObj[key]; @@ -145,7 +147,7 @@ const ViewAllResults = (props) => { resultsRowArr.push(