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
+47 -35
View File
@@ -12,7 +12,7 @@ import { Field, change, reduxForm } from "redux-form";
import { setCurrentSection } from "../store/appealType/action"; import { setCurrentSection } from "../store/appealType/action";
import { import {
setRepresentationCapacity, setRepresentationCapacity,
setRepresentationSubmit, setRepresentationSubmit
} from "../store/currentView/action"; } from "../store/currentView/action";
const Breadcrumbs = (props) => { const Breadcrumbs = (props) => {
const { const {
@@ -20,7 +20,7 @@ const Breadcrumbs = (props) => {
setCurrentView, setCurrentView,
setCurrentSection, setCurrentSection,
setRepresentationCapacity, setRepresentationCapacity,
setRepresentationSubmit, setRepresentationSubmit
} = props; } = props;
const router = useRouter(); const router = useRouter();
let { t } = useTranslation(); let { t } = useTranslation();
@@ -551,17 +551,25 @@ const Breadcrumbs = (props) => {
<> <>
<li className="govuk-breadcrumbs__list-item"> <li className="govuk-breadcrumbs__list-item">
<Link <Link
href={ href={{
"/searchresults?q=" + pathname:
props.props.search.searchString (session ? "/myportal" : "") +
} (router.query.adv == "true"
// onClick={() => { ? "/advancedsearchresults"
// // spinnerState(); : router.query.ads == "true"
// router.back(); ? "/addresssearchresults"
// }} : "/searchresults"),
query: router.query
}}
className="govuk-breadcrumbs__link" className="govuk-breadcrumbs__link"
> >
{t("common:breadcrumb-search-results")} {router.query.ads == "true"
? t(
"common:breadcrumb-addresssearch-results"
)
: t(
"common:breadcrumb-search-results"
)}
</Link> </Link>
</li> </li>
<li className="govuk-breadcrumbs__list-item"> <li className="govuk-breadcrumbs__list-item">
@@ -602,10 +610,6 @@ const Breadcrumbs = (props) => {
props.props.search props.props.search
.searchString .searchString
} }
onClick={() => {
// spinnerState();
router.back();
}}
className="govuk-breadcrumbs__link" className="govuk-breadcrumbs__link"
> >
{t( {t(
@@ -704,23 +708,29 @@ const Breadcrumbs = (props) => {
</li> </li>
<li className="govuk-breadcrumbs__list-item"> <li className="govuk-breadcrumbs__list-item">
<Link <Link
href={ href={{
router.locale != "en" pathname:
? router.locale + (session ? "/myportal" : "") +
"/fymhorth/searchresults?q=" + (router.query.adv == "true"
props.props.search ? "/advancedsearchresults"
.searchString : router.query.ads == "true"
: "/myportal/searchresults?q=" + ? "/addresssearchresults"
props.props.search : "/searchresults"),
.searchString query: router.query
}
onClick={() => {
// spinnerState();
router.back();
}} }}
className="govuk-breadcrumbs__link" className="govuk-breadcrumbs__link"
> >
{t("common:breadcrumb-search-results")} {router.query.adv == "true"
? t(
"common:breadcrumb-advanced-search-results"
)
: router.query.ads == "true"
? t(
"common:breadcrumb-address-search-results"
)
: t(
"common:breadcrumb-search-results"
)}
</Link> </Link>
</li> </li>
<li className="govuk-breadcrumbs__list-item"> <li className="govuk-breadcrumbs__list-item">
@@ -827,11 +837,13 @@ const Breadcrumbs = (props) => {
router.locale != "en" router.locale != "en"
? router.locale + ? router.locale +
"/searchresults?q=" + "/searchresults?q=" +
props.props.search router.query.q +
.searchString "&page=" +
router.query.page
: "/searchresults?q=" + : "/searchresults?q=" +
props.props.search router.query.q +
.searchString "&page=" +
router.query.page
} }
onClick={() => { onClick={() => {
// spinnerState(); // spinnerState();
@@ -1193,7 +1205,7 @@ const Breadcrumbs = (props) => {
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
return { return {
...state, ...state
}; };
}; };
@@ -1214,7 +1226,7 @@ const mapDispatchToProps = (dispatch) => {
}, },
setCurrentSection: (currentSection) => { setCurrentSection: (currentSection) => {
dispatch(setCurrentSection(currentSection)); dispatch(setCurrentSection(currentSection));
}, }
}; };
}; };
+33 -44
View File
@@ -786,6 +786,7 @@ const CaseSummary = (props) => {
<> <>
<div className="govuk-grid-row"> <div className="govuk-grid-row">
<div className="govuk-grid-column-full"> <div className="govuk-grid-column-full">
<div className="">
<div className="govuk-button-group"> <div className="govuk-button-group">
{getFormCollectionByID( {getFormCollectionByID(
appealTypeID appealTypeID
@@ -835,21 +836,10 @@ const CaseSummary = (props) => {
"case:summary-make-representation-label" "case:summary-make-representation-label"
)} )}
</Link> </Link>
<a
onClick={() => {
//spinnerState();
router.back();
}}
className="govuk-button govuk-button--secondary"
>
{t(
"case:summary-back-button-label"
)}
</a>
</> </>
) : !isLPA && ) : !isLPA &&
props.currentView props
.currentView
.caseReference .caseReference
.appealType == .appealType ==
846040004 ? ( 846040004 ? (
@@ -946,21 +936,10 @@ const CaseSummary = (props) => {
"case:summary-make-representation-label" "case:summary-make-representation-label"
)} )}
</Link> </Link>
<a
onClick={() => {
//spinnerState();
router.back();
}}
className="govuk-button govuk-button--secondary"
>
{t(
"case:summary-back-button-label"
)}
</a>
</> </>
) : !isLPA && ) : !isLPA &&
props.currentView props
.currentView
.caseReference .caseReference
.appealType == .appealType ==
846040004 ? ( 846040004 ? (
@@ -1014,7 +993,34 @@ const CaseSummary = (props) => {
)} )}
</> </>
)} )}
<div className="govuk-body">
<Link
className="govuk-button govuk-button--secondary"
href={{
pathname:
(session
? "/myportal"
: "") +
(router.query
.adv ==
"true"
? "/advancedsearchresults"
: router
.query
.ads ==
"true"
? "/addresssearchresults"
: "/searchresults"),
query: router.query
}}
>
{" "}
{t(
"case:summary-back-button-label"
)}
</Link>
</div>
<div className="govuk-button-group">
{session && {session &&
(isWatchedCase( (isWatchedCase(
props.currentView props.currentView
@@ -1245,13 +1251,6 @@ const CaseSummary = (props) => {
"case:send-email-notifications" "case:send-email-notifications"
)} )}
</button> </button>
{/* <button
onClick={
handleOpenModal
}
>
Open Modal
</button> */}
</> </>
))} ))}
{!session && ( {!session && (
@@ -1939,16 +1938,6 @@ const CaseSummary = (props) => {
)} )}
</Link> </Link>
)} )}
<a
onClick={() => {
// spinnerState();
router.back();
}}
className="govuk-button govuk-button--secondary"
>
{t("case:summary-back-button-label")}
</a>
</div> </div>
</div> </div>
</div> </div>
+42 -52
View File
@@ -13,11 +13,11 @@ import { useEffect } from "react";
import { setLoggedInUserId } from "../../store/accountDetails/action"; import { setLoggedInUserId } from "../../store/accountDetails/action";
import { import {
setSearchDetails, setSearchDetails,
setSearchResults, setSearchResults
} from "../../store/searchOutput/action"; } from "../../store/searchOutput/action";
import { import {
setWatchedCases, setWatchedCases,
setWatchedCasesDetails, setWatchedCasesDetails
} from "../../store/watchedCases/action"; } from "../../store/watchedCases/action";
import { getDetailsProxy } from "../utils"; import { getDetailsProxy } from "../utils";
@@ -27,7 +27,7 @@ import { signIn, useSession } from "next-auth/react";
import { import {
createWatchedCases, createWatchedCases,
deleteWatchedCases, deleteWatchedCases,
getWatchedCasesProxy, getWatchedCasesProxy
} from "../../actions"; } from "../../actions";
import RepsOnResults from "./repsonresults"; import RepsOnResults from "./repsonresults";
@@ -71,7 +71,7 @@ const SearchResults = (props) => {
setWatchedCases, setWatchedCases,
setWatchedCasesDetails, setWatchedCasesDetails,
isLinkedCase, isLinkedCase,
showLoginCheck, showLoginCheck
} = props; } = props;
let { t } = useTranslation(); let { t } = useTranslation();
@@ -109,7 +109,7 @@ const SearchResults = (props) => {
let updateBody = { let updateBody = {
"pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")", "pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")",
"pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")", "pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")",
"pinswg_appealcasetype": +appealType, "pinswg_appealcasetype": +appealType
}; };
createWatchedCases(updateBody) createWatchedCases(updateBody)
@@ -117,12 +117,12 @@ const SearchResults = (props) => {
.then(() => { .then(() => {
getWatchedCasesProxy(props.accountDetails.loggedinUserId).then( getWatchedCasesProxy(props.accountDetails.loggedinUserId).then(
(data) => { (data) => {
setWatchedCases(data), (setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then( getDetailsProxy(data, "myWatchedCases").then(
(data) => { (data) => {
setWatchedCasesDetails(data); setWatchedCasesDetails(data);
} }
); ));
} }
); );
}); });
@@ -138,7 +138,7 @@ const SearchResults = (props) => {
"pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")", "pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")",
"pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")", "pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")",
"pinswg_appealcasetype": +appealType, "pinswg_appealcasetype": +appealType,
"pinswg_emailnotifications": true, "pinswg_emailnotifications": true
}; };
console.log("Email signed up"); console.log("Email signed up");
@@ -147,12 +147,12 @@ const SearchResults = (props) => {
.then(() => { .then(() => {
getWatchedCasesProxy(props.accountDetails.loggedinUserId).then( getWatchedCasesProxy(props.accountDetails.loggedinUserId).then(
(data) => { (data) => {
setWatchedCases(data), (setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then( getDetailsProxy(data, "myWatchedCases").then(
(data) => { (data) => {
setWatchedCasesDetails(data); setWatchedCasesDetails(data);
} }
); ));
} }
); );
}); });
@@ -165,7 +165,7 @@ const SearchResults = (props) => {
whichIncident + whichIncident +
"')]", "')]",
json: watchedCases, json: watchedCases,
eval: true, eval: true
}); });
return isWatched; return isWatched;
@@ -179,7 +179,7 @@ const SearchResults = (props) => {
"' && @.pinswg_emailnotifications==true)]", "' && @.pinswg_emailnotifications==true)]",
json: watchedCases, json: watchedCases,
eval: true, eval: true
}); });
return isEmail; return isEmail;
}; };
@@ -203,7 +203,7 @@ const SearchResults = (props) => {
let newObj = {}; let newObj = {};
return Object.assign(newObj, { return Object.assign(newObj, {
"@odata.count": required.length, "@odata.count": required.length,
"value": required, "value": required
}); });
}; };
@@ -214,12 +214,12 @@ const SearchResults = (props) => {
var dateB = new Date(b.createdon); var dateB = new Date(b.createdon);
return dateB - dateA; return dateB - dateA;
}); });
setWatchedCases(data), (setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then( getDetailsProxy(data, "myWatchedCases").then(
(data) => { (data) => {
setWatchedCasesDetails(data); setWatchedCasesDetails(data);
} }
); ));
}); });
}); });
}; };
@@ -354,7 +354,7 @@ const SearchResults = (props) => {
'")]', '")]',
json: searchDetailsObj, json: searchDetailsObj,
eval: true, eval: true
}); });
detailsObj = detailsObj[0]; detailsObj = detailsObj[0];
return ( return (
@@ -364,7 +364,8 @@ const SearchResults = (props) => {
> >
<dd className="govuk-summary-list__value govuk-!-font-size-16 "> <dd className="govuk-summary-list__value govuk-!-font-size-16 ">
<Link <Link
href={ href={{
pathname:
(router.locale == "cy" (router.locale == "cy"
? myportal == true ? myportal == true
? "/fymhorth/achos" ? "/fymhorth/achos"
@@ -373,25 +374,14 @@ const SearchResults = (props) => {
? "/myportal/case" ? "/myportal/case"
: "/case") + : "/case") +
"/" + "/" +
item.ticketnumber item.ticketnumber,
query: {
...router.query,
adv: "false",
ads: "true"
} }
}}
className="govuk-link--no-underline" 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"> <span className="results-visually-hidden">
{t( {t(
@@ -578,7 +568,7 @@ const SearchResults = (props) => {
: :
</span> </span>
{_.has(detailsObj, [ {_.has(detailsObj, [
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue", "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
]) ])
? detailsObj[ ? detailsObj[
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue" "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
@@ -593,7 +583,7 @@ const SearchResults = (props) => {
: :
</span> </span>
{_.has(item, [ {_.has(item, [
"_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue", "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue"
]) ])
? router.locale == "cy" ? router.locale == "cy"
? jsonpath({ ? jsonpath({
@@ -604,14 +594,14 @@ const SearchResults = (props) => {
] + ] +
'")].value_cy', '")].value_cy',
json: transLookup, json: transLookup,
eval: true, eval: true
}) })
: item[ : item[
"_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue"
] || "N/A" ] || "N/A"
: ""} : ""}
{_.has(item, [ {_.has(item, [
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue", "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
]) ])
? router.locale == "cy" ? router.locale == "cy"
? jsonpath({ ? jsonpath({
@@ -622,7 +612,7 @@ const SearchResults = (props) => {
] + ] +
'")].value_cy', '")].value_cy',
json: transLookup, json: transLookup,
eval: true, eval: true
}) })
: item[ : item[
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
@@ -658,7 +648,7 @@ const SearchResults = (props) => {
] + ] +
'")].value_cy', '")].value_cy',
json: transLookup, json: transLookup,
eval: true, eval: true
}) })
: item["pinswg_appealType"] || : item["pinswg_appealType"] ||
"N/A"} "N/A"}
@@ -680,7 +670,7 @@ const SearchResults = (props) => {
] + ] +
'")].value_cy', '")].value_cy',
json: transLookup, json: transLookup,
eval: true, eval: true
}) })
: item[ : item[
"statuscode@OData.Community.Display.V1.FormattedValue" "statuscode@OData.Community.Display.V1.FormattedValue"
@@ -834,7 +824,7 @@ const SearchResults = (props) => {
"&toWatch=" + "&toWatch=" +
item.incidentid + item.incidentid +
"_" + "_" +
item.pinswg_appealcasetype, item.pinswg_appealcasetype
}); });
}} }}
title={t( title={t(
@@ -865,7 +855,7 @@ const SearchResults = (props) => {
"&toWatch=" + "&toWatch=" +
item.incidentid + item.incidentid +
"_" + "_" +
item.pinswg_appealcasetype, item.pinswg_appealcasetype
}); });
}} }}
> >
@@ -903,7 +893,7 @@ const SearchResults = (props) => {
resultsArr = _.sortBy(resultsArr, [ resultsArr = _.sortBy(resultsArr, [
function (o) { function (o) {
return o[orderBy]; return o[orderBy];
}, }
]); ]);
fieldSort == "desc" && resultsArr.reverse(); fieldSort == "desc" && resultsArr.reverse();
@@ -946,7 +936,7 @@ const SearchResults = (props) => {
"pinswg_WatchedCase@odata.bind": "pinswg_WatchedCase@odata.bind":
"/incidents(" + incidentID + ")", "/incidents(" + incidentID + ")",
"pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")", "pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")",
"pinswg_appealcasetype": +appealType, "pinswg_appealcasetype": +appealType
}; };
createWatchedCases(updateBody) createWatchedCases(updateBody)
@@ -955,12 +945,12 @@ const SearchResults = (props) => {
getWatchedCasesProxy( getWatchedCasesProxy(
props.accountDetails.loggedinUserId props.accountDetails.loggedinUserId
).then((data) => { ).then((data) => {
setWatchedCases(data), (setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then( getDetailsProxy(data, "myWatchedCases").then(
(data) => { (data) => {
setWatchedCasesDetails(data); setWatchedCasesDetails(data);
} }
); ));
}); });
}); });
}; };
@@ -983,7 +973,7 @@ const SearchResults = (props) => {
setLoggedInUserId(props.accountDetails.loggedinUserId); setLoggedInUserId(props.accountDetails.loggedinUserId);
setCookie(null, "pinsUser", props.accountDetails.loggedinUserId, { setCookie(null, "pinsUser", props.accountDetails.loggedinUserId, {
path: "/", path: "/",
expires: expDate, expires: expDate
}); });
selectWatchedCase( selectWatchedCase(
props.accountDetails.loggedinUserId, props.accountDetails.loggedinUserId,
@@ -1006,7 +996,7 @@ const SearchResults = (props) => {
getSearchPageResults, getSearchPageResults,
setWatchedCasesDetails, setWatchedCasesDetails,
props.accountDetails.loggedinUserId, props.accountDetails.loggedinUserId,
router.query, router.query
]); ]);
return ( return (
@@ -1024,7 +1014,7 @@ const SearchResults = (props) => {
{resultsArr.length > 200 {resultsArr.length > 200
? t("search:searchresults-max-count-label") ? t("search:searchresults-max-count-label")
: t("search:searchresults-count-label", { : t("search:searchresults-count-label", {
count: searchResultsObj["@odata.count"], count: searchResultsObj["@odata.count"]
})} })}
. .
{advancedSearch != true ? ( {advancedSearch != true ? (
@@ -1108,7 +1098,7 @@ const mapDispatchToProps = (dispatch) => {
}, },
setWatchedCasesDetails: (watchedCasesDetails) => { setWatchedCasesDetails: (watchedCasesDetails) => {
dispatch(setWatchedCasesDetails(watchedCasesDetails)); dispatch(setWatchedCasesDetails(watchedCasesDetails));
}, }
// setCurrentPage: (currentPage) => { // setCurrentPage: (currentPage) => {
// dispatch(setCurrentPage(currentPage)); // dispatch(setCurrentPage(currentPage));
// }, // },
@@ -1118,7 +1108,7 @@ const mapDispatchToProps = (dispatch) => {
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
return { return {
// currentView: state.currentView, // currentView: state.currentView,
accountDetails: state.accountDetails, accountDetails: state.accountDetails
// search: state.search, // search: state.search,
// searchResultsObj: state.searchResultsObj, // searchResultsObj: state.searchResultsObj,
}; };
+50 -42
View File
@@ -9,7 +9,7 @@ import { getAdvancedSearchPaged, getBasicSearchPaged } from "../../actions";
import transLookup from "../../data/lookuptranslations.json"; import transLookup from "../../data/lookuptranslations.json";
import { import {
setCurrentPage, setCurrentPage,
setCurrentReference, setCurrentReference
} from "../../store/currentView/action"; } from "../../store/currentView/action";
import { parseCookies, setCookie } from "nookies"; import { parseCookies, setCookie } from "nookies";
@@ -17,11 +17,11 @@ import { useEffect } from "react";
import { setLoggedInUserId } from "../../store/accountDetails/action"; import { setLoggedInUserId } from "../../store/accountDetails/action";
import { import {
setSearchDetails, setSearchDetails,
setSearchResults, setSearchResults
} from "../../store/searchOutput/action"; } from "../../store/searchOutput/action";
import { import {
setWatchedCases, setWatchedCases,
setWatchedCasesDetails, setWatchedCasesDetails
} from "../../store/watchedCases/action"; } from "../../store/watchedCases/action";
import { getDetailsProxy, getSearchDetailsPaged } from "../utils"; import { getDetailsProxy, getSearchDetailsPaged } from "../utils";
@@ -31,11 +31,12 @@ import { signIn, useSession } from "next-auth/react";
import { import {
createWatchedCases, createWatchedCases,
deleteWatchedCases, deleteWatchedCases,
getWatchedCasesProxy, getWatchedCasesProxy
} from "../../actions"; } from "../../actions";
import { sendGAEvent } from "@next/third-parties/google"; import { sendGAEvent } from "@next/third-parties/google";
import RepsOnResults from "./repsonresults"; import RepsOnResults from "./repsonresults";
import { query } from "jsonpath";
const escapeRegExp = (string) => string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); const escapeRegExp = (string) => string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -78,7 +79,7 @@ const SearchResults = (props) => {
setWatchedCasesDetails, setWatchedCasesDetails,
isLinkedCase, isLinkedCase,
setCurrentPage, setCurrentPage,
showLoginCheck, showLoginCheck
} = props; } = props;
let { t } = useTranslation(); let { t } = useTranslation();
@@ -116,7 +117,7 @@ const SearchResults = (props) => {
let updateBody = { let updateBody = {
"pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")", "pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")",
"pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")", "pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")",
"pinswg_appealcasetype": +appealType, "pinswg_appealcasetype": +appealType
}; };
createWatchedCases(updateBody) createWatchedCases(updateBody)
@@ -124,12 +125,12 @@ const SearchResults = (props) => {
.then(() => { .then(() => {
getWatchedCasesProxy(props.accountDetails.loggedinUserId).then( getWatchedCasesProxy(props.accountDetails.loggedinUserId).then(
(data) => { (data) => {
setWatchedCases(data), (setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then( getDetailsProxy(data, "myWatchedCases").then(
(data) => { (data) => {
setWatchedCasesDetails(data); setWatchedCasesDetails(data);
} }
); ));
} }
); );
}); });
@@ -145,7 +146,7 @@ const SearchResults = (props) => {
"pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")", "pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")",
"pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")", "pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")",
"pinswg_appealcasetype": +appealType, "pinswg_appealcasetype": +appealType,
"pinswg_emailnotifications": true, "pinswg_emailnotifications": true
}; };
console.log("Email signed up"); console.log("Email signed up");
@@ -154,12 +155,12 @@ const SearchResults = (props) => {
.then(() => { .then(() => {
getWatchedCasesProxy(props.accountDetails.loggedinUserId).then( getWatchedCasesProxy(props.accountDetails.loggedinUserId).then(
(data) => { (data) => {
setWatchedCases(data), (setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then( getDetailsProxy(data, "myWatchedCases").then(
(data) => { (data) => {
setWatchedCasesDetails(data); setWatchedCasesDetails(data);
} }
); ));
} }
); );
}); });
@@ -173,7 +174,7 @@ const SearchResults = (props) => {
"')]", "')]",
json: watchedCases, json: watchedCases,
eval: true, eval: true
}); });
return isWatched; return isWatched;
@@ -187,7 +188,7 @@ const SearchResults = (props) => {
"' && @.pinswg_emailnotifications==true)]", "' && @.pinswg_emailnotifications==true)]",
json: watchedCases, json: watchedCases,
eval: true, eval: true
}); });
return isEmail; return isEmail;
}; };
@@ -200,7 +201,7 @@ const SearchResults = (props) => {
"')]", "')]",
json: watchedCases, json: watchedCases,
eval: true, eval: true
}); });
return isWatched; return isWatched;
@@ -225,7 +226,7 @@ const SearchResults = (props) => {
let newObj = {}; let newObj = {};
return Object.assign(newObj, { return Object.assign(newObj, {
"@odata.count": required.length, "@odata.count": required.length,
"value": required, "value": required
}); });
}; };
@@ -236,12 +237,12 @@ const SearchResults = (props) => {
var dateB = new Date(b.createdon); var dateB = new Date(b.createdon);
return dateB - dateA; return dateB - dateA;
}); });
setWatchedCases(data), (setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then( getDetailsProxy(data, "myWatchedCases").then(
(data) => { (data) => {
setWatchedCasesDetails(data); setWatchedCasesDetails(data);
} }
); ));
}); });
}); });
}; };
@@ -259,7 +260,7 @@ const SearchResults = (props) => {
? searchString.map(([key, val]) => val).filter(Boolean) ? searchString.map(([key, val]) => val).filter(Boolean)
: searchString; : searchString;
const ResultsView = (resultsArr) => { const ResultsView = (resultsArr, currPage) => {
return ( return (
<> <>
<dl className="govuk-summary-list govuk-!-margin-bottom-9 results"> <dl className="govuk-summary-list govuk-!-margin-bottom-9 results">
@@ -374,7 +375,7 @@ const SearchResults = (props) => {
item.ticketnumber + item.ticketnumber +
'")]', '")]',
json: searchDetailsObj, json: searchDetailsObj,
eval: true, eval: true
}); });
Object.assign(item, item.pinswg_sipscase); Object.assign(item, item.pinswg_sipscase);
@@ -388,7 +389,8 @@ const SearchResults = (props) => {
<dd className="govuk-summary-list__value govuk-!-font-size-16 "> <dd className="govuk-summary-list__value govuk-!-font-size-16 ">
<div></div> <div></div>
<Link <Link
href={ href={{
pathname:
(router.locale == "cy" (router.locale == "cy"
? myportal == true ? myportal == true
? "/fymhorth/achos" ? "/fymhorth/achos"
@@ -397,16 +399,22 @@ const SearchResults = (props) => {
? "/myportal/case" ? "/myportal/case"
: "/case") + : "/case") +
"/" + "/" +
item.ticketnumber item.ticketnumber,
query: {
...router.query,
adv: advancedSearch
? "true"
: "false"
} }
}}
className="govuk-link--no-underline" className="govuk-link--no-underline"
onClick={() => { onClick={() => {
sendGAEvent( (sendGAEvent(
"event", "event",
"CaseViewed", "CaseViewed",
{ {
caseReference: caseReference:
item.ticketnumber, item.ticketnumber
} }
), ),
setCurrentReference({ setCurrentReference({
@@ -431,8 +439,8 @@ const SearchResults = (props) => {
"pinswg_specialistcaseprocess" "pinswg_specialistcaseprocess"
) )
? detailsObj.pinswg_specialistcaseprocess ? detailsObj.pinswg_specialistcaseprocess
: "", : ""
}); }));
}} }}
> >
<span className="results-visually-hidden"> <span className="results-visually-hidden">
@@ -585,7 +593,7 @@ const SearchResults = (props) => {
" " + " " +
item.pinswg_appellantlastname item.pinswg_appellantlastname
: _.has(detailsObj, [ : _.has(detailsObj, [
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue", "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
]) ])
? detailsObj[ ? detailsObj[
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue" "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
@@ -600,7 +608,7 @@ const SearchResults = (props) => {
: :
</span> </span>
{_.has(item, [ {_.has(item, [
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue", "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
]) ])
? router.locale == "cy" ? router.locale == "cy"
? jsonpath({ ? jsonpath({
@@ -611,7 +619,7 @@ const SearchResults = (props) => {
] + ] +
'")].value_cy', '")].value_cy',
json: transLookup, json: transLookup,
eval: true, eval: true
}) })
: item[ : item[
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
@@ -647,7 +655,7 @@ const SearchResults = (props) => {
] + ] +
'")].value_cy', '")].value_cy',
json: transLookup, json: transLookup,
eval: true, eval: true
}) })
: item[ : item[
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
@@ -670,7 +678,7 @@ const SearchResults = (props) => {
] + ] +
'")].value_cy', '")].value_cy',
json: transLookup, json: transLookup,
eval: true, eval: true
}) })
: item[ : item[
"statuscode@OData.Community.Display.V1.FormattedValue" "statuscode@OData.Community.Display.V1.FormattedValue"
@@ -821,7 +829,7 @@ const SearchResults = (props) => {
"&toWatch=" + "&toWatch=" +
item.incidentid + item.incidentid +
"_" + "_" +
item.pinswg_appealcasetype, item.pinswg_appealcasetype
}); });
}} }}
title={t( title={t(
@@ -949,7 +957,7 @@ const SearchResults = (props) => {
searchString, searchString,
selectedOption, selectedOption,
setSearchDetails, setSearchDetails,
setSearchResults, setSearchResults
] ]
); );
@@ -973,7 +981,7 @@ const SearchResults = (props) => {
"pinswg_WatchedCase@odata.bind": "pinswg_WatchedCase@odata.bind":
"/incidents(" + incidentID + ")", "/incidents(" + incidentID + ")",
"pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")", "pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")",
"pinswg_appealcasetype": +appealType, "pinswg_appealcasetype": +appealType
}; };
createWatchedCases(updateBody) createWatchedCases(updateBody)
@@ -982,12 +990,12 @@ const SearchResults = (props) => {
getWatchedCasesProxy( getWatchedCasesProxy(
props.accountDetails.loggedinUserId props.accountDetails.loggedinUserId
).then((data) => { ).then((data) => {
setWatchedCases(data), (setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then( getDetailsProxy(data, "myWatchedCases").then(
(data) => { (data) => {
setWatchedCasesDetails(data); setWatchedCasesDetails(data);
} }
); ));
}); });
}); });
}; };
@@ -1010,7 +1018,7 @@ const SearchResults = (props) => {
setLoggedInUserId(props.accountDetails.loggedinUserId); setLoggedInUserId(props.accountDetails.loggedinUserId);
setCookie(null, "pinsUser", props.accountDetails.loggedinUserId, { setCookie(null, "pinsUser", props.accountDetails.loggedinUserId, {
path: "/", path: "/",
expires: expDate, expires: expDate
}); });
selectWatchedCase( selectWatchedCase(
props.accountDetails.loggedinUserId, props.accountDetails.loggedinUserId,
@@ -1033,7 +1041,7 @@ const SearchResults = (props) => {
getSearchPageResults, getSearchPageResults,
setWatchedCasesDetails, setWatchedCasesDetails,
props.accountDetails.loggedinUserId, props.accountDetails.loggedinUserId,
router.query, router.query
]); ]);
//console.log( //console.log(
// "page is here ", // "page is here ",
@@ -1059,7 +1067,7 @@ const SearchResults = (props) => {
: t("search:searchresults-count-label", { : t("search:searchresults-count-label", {
count: searchResultsObj[ count: searchResultsObj[
"@odata.count" "@odata.count"
], ]
})} })}
. .
{advancedSearch != true ? ( {advancedSearch != true ? (
@@ -1122,7 +1130,7 @@ const SearchResults = (props) => {
</div> </div>
)} )}
{resultsArr.length > 0 ? ( {resultsArr.length > 0 ? (
ResultsView(resultsArr) ResultsView(resultsArr, props.currentView.currentPage)
) : ( ) : (
<div className="govuk-grid-row"> <div className="govuk-grid-row">
<div className="govuk-grid-column-two-thirds"> <div className="govuk-grid-column-two-thirds">
@@ -1157,14 +1165,14 @@ const mapDispatchToProps = (dispatch) => {
}, },
setCurrentPage: (currentPage) => { setCurrentPage: (currentPage) => {
dispatch(setCurrentPage(currentPage)); dispatch(setCurrentPage(currentPage));
}, }
}; };
}; };
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
return { return {
// currentView: state.currentView, currentView: state.currentView,
accountDetails: state.accountDetails, accountDetails: state.accountDetails
// search: state.search, // search: state.search,
// searchResultsObj: state.searchResultsObj, // searchResultsObj: state.searchResultsObj,
}; };