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
+58 -68
View File
@@ -13,11 +13,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 } from "../utils";
@@ -27,7 +27,7 @@ import { signIn, useSession } from "next-auth/react";
import {
createWatchedCases,
deleteWatchedCases,
getWatchedCasesProxy,
getWatchedCasesProxy
} from "../../actions";
import RepsOnResults from "./repsonresults";
@@ -71,7 +71,7 @@ const SearchResults = (props) => {
setWatchedCases,
setWatchedCasesDetails,
isLinkedCase,
showLoginCheck,
showLoginCheck
} = props;
let { t } = useTranslation();
@@ -109,7 +109,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)
@@ -117,12 +117,12 @@ const SearchResults = (props) => {
.then(() => {
getWatchedCasesProxy(props.accountDetails.loggedinUserId).then(
(data) => {
setWatchedCases(data),
(setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then(
(data) => {
setWatchedCasesDetails(data);
}
);
));
}
);
});
@@ -138,7 +138,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");
@@ -147,12 +147,12 @@ const SearchResults = (props) => {
.then(() => {
getWatchedCasesProxy(props.accountDetails.loggedinUserId).then(
(data) => {
setWatchedCases(data),
(setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then(
(data) => {
setWatchedCasesDetails(data);
}
);
));
}
);
});
@@ -165,7 +165,7 @@ const SearchResults = (props) => {
whichIncident +
"')]",
json: watchedCases,
eval: true,
eval: true
});
return isWatched;
@@ -179,7 +179,7 @@ const SearchResults = (props) => {
"' && @.pinswg_emailnotifications==true)]",
json: watchedCases,
eval: true,
eval: true
});
return isEmail;
};
@@ -203,7 +203,7 @@ const SearchResults = (props) => {
let newObj = {};
return Object.assign(newObj, {
"@odata.count": required.length,
"value": required,
"value": required
});
};
@@ -214,12 +214,12 @@ const SearchResults = (props) => {
var dateB = new Date(b.createdon);
return dateB - dateA;
});
setWatchedCases(data),
(setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then(
(data) => {
setWatchedCasesDetails(data);
}
);
));
});
});
};
@@ -354,7 +354,7 @@ const SearchResults = (props) => {
'")]',
json: searchDetailsObj,
eval: true,
eval: true
});
detailsObj = detailsObj[0];
return (
@@ -364,34 +364,24 @@ const SearchResults = (props) => {
>
<dd className="govuk-summary-list__value govuk-!-font-size-16 ">
<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: "false",
ads: "true"
}
}}
className="govuk-link--no-underline"
// onClick={() => {
// setCurrentReference({
// "ticketnumber":
// item.ticketnumber,
// "currentReference":
// item.title,
// "currentType":
// "searchResultsObj",
// "incidentid":
// item.incidentid,
// "appealType":
// item.pinswg_appealcasetype,
// "showLoginCheck":
// props.showLoginCheck,
// });
// }}
>
<span className="results-visually-hidden">
{t(
@@ -424,13 +414,13 @@ const SearchResults = (props) => {
) < 0
? detailsObj.pinswg_projectlocation
: router.locale ==
"cy"
? detailsObj.pinswg_projectlocation.split(
";"
)[1]
: detailsObj.pinswg_projectlocation.split(
";"
)[0]
"cy"
? detailsObj.pinswg_projectlocation.split(
";"
)[1]
: detailsObj.pinswg_projectlocation.split(
";"
)[0]
: "",
highlightQuery
)
@@ -578,7 +568,7 @@ const SearchResults = (props) => {
:
</span>
{_.has(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"
@@ -593,7 +583,7 @@ const SearchResults = (props) => {
:
</span>
{_.has(item, [
"_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue",
"_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue"
])
? router.locale == "cy"
? jsonpath({
@@ -604,14 +594,14 @@ const SearchResults = (props) => {
] +
'")].value_cy',
json: transLookup,
eval: true,
eval: true
})
: item[
"_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue"
] || "N/A"
: ""}
{_.has(item, [
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue",
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
])
? router.locale == "cy"
? jsonpath({
@@ -622,7 +612,7 @@ const SearchResults = (props) => {
] +
'")].value_cy',
json: transLookup,
eval: true,
eval: true
})
: item[
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
@@ -658,7 +648,7 @@ const SearchResults = (props) => {
] +
'")].value_cy',
json: transLookup,
eval: true,
eval: true
})
: item["pinswg_appealType"] ||
"N/A"}
@@ -680,7 +670,7 @@ const SearchResults = (props) => {
] +
'")].value_cy',
json: transLookup,
eval: true,
eval: true
})
: item[
"statuscode@OData.Community.Display.V1.FormattedValue"
@@ -834,7 +824,7 @@ const SearchResults = (props) => {
"&toWatch=" +
item.incidentid +
"_" +
item.pinswg_appealcasetype,
item.pinswg_appealcasetype
});
}}
title={t(
@@ -865,7 +855,7 @@ const SearchResults = (props) => {
"&toWatch=" +
item.incidentid +
"_" +
item.pinswg_appealcasetype,
item.pinswg_appealcasetype
});
}}
>
@@ -903,7 +893,7 @@ const SearchResults = (props) => {
resultsArr = _.sortBy(resultsArr, [
function (o) {
return o[orderBy];
},
}
]);
fieldSort == "desc" && resultsArr.reverse();
@@ -946,7 +936,7 @@ const SearchResults = (props) => {
"pinswg_WatchedCase@odata.bind":
"/incidents(" + incidentID + ")",
"pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")",
"pinswg_appealcasetype": +appealType,
"pinswg_appealcasetype": +appealType
};
createWatchedCases(updateBody)
@@ -955,12 +945,12 @@ const SearchResults = (props) => {
getWatchedCasesProxy(
props.accountDetails.loggedinUserId
).then((data) => {
setWatchedCases(data),
(setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then(
(data) => {
setWatchedCasesDetails(data);
}
);
));
});
});
};
@@ -983,7 +973,7 @@ const SearchResults = (props) => {
setLoggedInUserId(props.accountDetails.loggedinUserId);
setCookie(null, "pinsUser", props.accountDetails.loggedinUserId, {
path: "/",
expires: expDate,
expires: expDate
});
selectWatchedCase(
props.accountDetails.loggedinUserId,
@@ -1006,7 +996,7 @@ const SearchResults = (props) => {
getSearchPageResults,
setWatchedCasesDetails,
props.accountDetails.loggedinUserId,
router.query,
router.query
]);
return (
@@ -1024,7 +1014,7 @@ const SearchResults = (props) => {
{resultsArr.length > 200
? t("search:searchresults-max-count-label")
: t("search:searchresults-count-label", {
count: searchResultsObj["@odata.count"],
count: searchResultsObj["@odata.count"]
})}
.
{advancedSearch != true ? (
@@ -1108,7 +1098,7 @@ const mapDispatchToProps = (dispatch) => {
},
setWatchedCasesDetails: (watchedCasesDetails) => {
dispatch(setWatchedCasesDetails(watchedCasesDetails));
},
}
// setCurrentPage: (currentPage) => {
// dispatch(setCurrentPage(currentPage));
// },
@@ -1118,7 +1108,7 @@ const mapDispatchToProps = (dispatch) => {
const mapStateToProps = (state) => {
return {
// currentView: state.currentView,
accountDetails: state.accountDetails,
accountDetails: state.accountDetails
// search: state.search,
// searchResultsObj: state.searchResultsObj,
};