correctly go back to the previous page search results

This commit is contained in:
2026-03-10 10:31:16 +00:00
parent e6c25d7ef5
commit 3e48f8cd28
4 changed files with 407 additions and 408 deletions
+73 -65
View File
@@ -9,7 +9,7 @@ import { getAdvancedSearchPaged, getBasicSearchPaged } from "../../actions";
import transLookup from "../../data/lookuptranslations.json";
import {
setCurrentPage,
setCurrentReference,
setCurrentReference
} from "../../store/currentView/action";
import { parseCookies, setCookie } from "nookies";
@@ -17,11 +17,11 @@ import { useEffect } from "react";
import { setLoggedInUserId } from "../../store/accountDetails/action";
import {
setSearchDetails,
setSearchResults,
setSearchResults
} from "../../store/searchOutput/action";
import {
setWatchedCases,
setWatchedCasesDetails,
setWatchedCasesDetails
} from "../../store/watchedCases/action";
import { getDetailsProxy, getSearchDetailsPaged } from "../utils";
@@ -31,11 +31,12 @@ import { signIn, useSession } from "next-auth/react";
import {
createWatchedCases,
deleteWatchedCases,
getWatchedCasesProxy,
getWatchedCasesProxy
} from "../../actions";
import { sendGAEvent } from "@next/third-parties/google";
import RepsOnResults from "./repsonresults";
import { query } from "jsonpath";
const escapeRegExp = (string) => string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -78,7 +79,7 @@ const SearchResults = (props) => {
setWatchedCasesDetails,
isLinkedCase,
setCurrentPage,
showLoginCheck,
showLoginCheck
} = props;
let { t } = useTranslation();
@@ -116,7 +117,7 @@ const SearchResults = (props) => {
let updateBody = {
"pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")",
"pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")",
"pinswg_appealcasetype": +appealType,
"pinswg_appealcasetype": +appealType
};
createWatchedCases(updateBody)
@@ -124,12 +125,12 @@ const SearchResults = (props) => {
.then(() => {
getWatchedCasesProxy(props.accountDetails.loggedinUserId).then(
(data) => {
setWatchedCases(data),
(setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then(
(data) => {
setWatchedCasesDetails(data);
}
);
));
}
);
});
@@ -145,7 +146,7 @@ const SearchResults = (props) => {
"pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")",
"pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")",
"pinswg_appealcasetype": +appealType,
"pinswg_emailnotifications": true,
"pinswg_emailnotifications": true
};
console.log("Email signed up");
@@ -154,12 +155,12 @@ const SearchResults = (props) => {
.then(() => {
getWatchedCasesProxy(props.accountDetails.loggedinUserId).then(
(data) => {
setWatchedCases(data),
(setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then(
(data) => {
setWatchedCasesDetails(data);
}
);
));
}
);
});
@@ -173,7 +174,7 @@ const SearchResults = (props) => {
"')]",
json: watchedCases,
eval: true,
eval: true
});
return isWatched;
@@ -187,7 +188,7 @@ const SearchResults = (props) => {
"' && @.pinswg_emailnotifications==true)]",
json: watchedCases,
eval: true,
eval: true
});
return isEmail;
};
@@ -200,7 +201,7 @@ const SearchResults = (props) => {
"')]",
json: watchedCases,
eval: true,
eval: true
});
return isWatched;
@@ -225,7 +226,7 @@ const SearchResults = (props) => {
let newObj = {};
return Object.assign(newObj, {
"@odata.count": required.length,
"value": required,
"value": required
});
};
@@ -236,12 +237,12 @@ const SearchResults = (props) => {
var dateB = new Date(b.createdon);
return dateB - dateA;
});
setWatchedCases(data),
(setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then(
(data) => {
setWatchedCasesDetails(data);
}
);
));
});
});
};
@@ -259,7 +260,7 @@ const SearchResults = (props) => {
? searchString.map(([key, val]) => val).filter(Boolean)
: searchString;
const ResultsView = (resultsArr) => {
const ResultsView = (resultsArr, currPage) => {
return (
<>
<dl className="govuk-summary-list govuk-!-margin-bottom-9 results">
@@ -374,7 +375,7 @@ const SearchResults = (props) => {
item.ticketnumber +
'")]',
json: searchDetailsObj,
eval: true,
eval: true
});
Object.assign(item, item.pinswg_sipscase);
@@ -388,25 +389,32 @@ const SearchResults = (props) => {
<dd className="govuk-summary-list__value govuk-!-font-size-16 ">
<div></div>
<Link
href={
(router.locale == "cy"
? myportal == true
? "/fymhorth/achos"
: "/achos"
: myportal == true
? "/myportal/case"
: "/case") +
"/" +
item.ticketnumber
}
href={{
pathname:
(router.locale == "cy"
? myportal == true
? "/fymhorth/achos"
: "/achos"
: myportal == true
? "/myportal/case"
: "/case") +
"/" +
item.ticketnumber,
query: {
...router.query,
adv: advancedSearch
? "true"
: "false"
}
}}
className="govuk-link--no-underline"
onClick={() => {
sendGAEvent(
(sendGAEvent(
"event",
"CaseViewed",
{
caseReference:
item.ticketnumber,
item.ticketnumber
}
),
setCurrentReference({
@@ -428,11 +436,11 @@ const SearchResults = (props) => {
)
? detailsObj.pinswg_speacialistcaseprocess
: detailsObj.hasOwnProperty(
"pinswg_specialistcaseprocess"
)
? detailsObj.pinswg_specialistcaseprocess
: "",
});
"pinswg_specialistcaseprocess"
)
? detailsObj.pinswg_specialistcaseprocess
: ""
}));
}}
>
<span className="results-visually-hidden">
@@ -486,12 +494,12 @@ const SearchResults = (props) => {
) < 0
? detailsObj.pinswg_projectlocation
: router.locale == "cy"
? detailsObj.pinswg_projectlocation.split(
";"
)[1]
: detailsObj.pinswg_projectlocation.split(
";"
)[0]
? detailsObj.pinswg_projectlocation.split(
";"
)[1]
: detailsObj.pinswg_projectlocation.split(
";"
)[0]
: ""
: // : hasValidKey(
// item,
@@ -585,12 +593,12 @@ const SearchResults = (props) => {
" " +
item.pinswg_appellantlastname
: _.has(detailsObj, [
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue",
])
? detailsObj[
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
]
: ""}
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
])
? detailsObj[
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
]
: ""}
</dd>
<dd className="govuk-summary-list__value govuk-!-font-size-16">
<span className="results-visually-hidden">
@@ -600,7 +608,7 @@ const SearchResults = (props) => {
:
</span>
{_.has(item, [
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue",
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
])
? router.locale == "cy"
? jsonpath({
@@ -611,7 +619,7 @@ const SearchResults = (props) => {
] +
'")].value_cy',
json: transLookup,
eval: true,
eval: true
})
: item[
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
@@ -647,7 +655,7 @@ const SearchResults = (props) => {
] +
'")].value_cy',
json: transLookup,
eval: true,
eval: true
})
: item[
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
@@ -670,7 +678,7 @@ const SearchResults = (props) => {
] +
'")].value_cy',
json: transLookup,
eval: true,
eval: true
})
: item[
"statuscode@OData.Community.Display.V1.FormattedValue"
@@ -821,7 +829,7 @@ const SearchResults = (props) => {
"&toWatch=" +
item.incidentid +
"_" +
item.pinswg_appealcasetype,
item.pinswg_appealcasetype
});
}}
title={t(
@@ -949,7 +957,7 @@ const SearchResults = (props) => {
searchString,
selectedOption,
setSearchDetails,
setSearchResults,
setSearchResults
]
);
@@ -973,7 +981,7 @@ const SearchResults = (props) => {
"pinswg_WatchedCase@odata.bind":
"/incidents(" + incidentID + ")",
"pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")",
"pinswg_appealcasetype": +appealType,
"pinswg_appealcasetype": +appealType
};
createWatchedCases(updateBody)
@@ -982,12 +990,12 @@ const SearchResults = (props) => {
getWatchedCasesProxy(
props.accountDetails.loggedinUserId
).then((data) => {
setWatchedCases(data),
(setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then(
(data) => {
setWatchedCasesDetails(data);
}
);
));
});
});
};
@@ -1010,7 +1018,7 @@ const SearchResults = (props) => {
setLoggedInUserId(props.accountDetails.loggedinUserId);
setCookie(null, "pinsUser", props.accountDetails.loggedinUserId, {
path: "/",
expires: expDate,
expires: expDate
});
selectWatchedCase(
props.accountDetails.loggedinUserId,
@@ -1033,7 +1041,7 @@ const SearchResults = (props) => {
getSearchPageResults,
setWatchedCasesDetails,
props.accountDetails.loggedinUserId,
router.query,
router.query
]);
//console.log(
// "page is here ",
@@ -1059,7 +1067,7 @@ const SearchResults = (props) => {
: t("search:searchresults-count-label", {
count: searchResultsObj[
"@odata.count"
],
]
})}
.
{advancedSearch != true ? (
@@ -1122,7 +1130,7 @@ const SearchResults = (props) => {
</div>
)}
{resultsArr.length > 0 ? (
ResultsView(resultsArr)
ResultsView(resultsArr, props.currentView.currentPage)
) : (
<div className="govuk-grid-row">
<div className="govuk-grid-column-two-thirds">
@@ -1157,14 +1165,14 @@ const mapDispatchToProps = (dispatch) => {
},
setCurrentPage: (currentPage) => {
dispatch(setCurrentPage(currentPage));
},
}
};
};
const mapStateToProps = (state) => {
return {
// currentView: state.currentView,
accountDetails: state.accountDetails,
currentView: state.currentView,
accountDetails: state.accountDetails
// search: state.search,
// searchResultsObj: state.searchResultsObj,
};