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
+51 -39
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();
@@ -38,10 +38,10 @@ const Breadcrumbs = (props) => {
currentView.caseReference.appealType == 846040008 currentView.caseReference.appealType == 846040008
? 7 ? 7
: currentView.caseReference.appealType == 846040005 || : currentView.caseReference.appealType == 846040005 ||
currentView.caseReference.appealType == 846040006 || currentView.caseReference.appealType == 846040006 ||
currentView.caseReference.appealType == 846040007 currentView.caseReference.appealType == 846040007
? 9 ? 9
: ""; : "";
var viewAllKey = currentView?.viewKey || router.query.viewKey; var viewAllKey = currentView?.viewKey || router.query.viewKey;
return ( return (
@@ -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));
}, }
}; };
}; };
+225 -236
View File
@@ -786,235 +786,241 @@ 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="govuk-button-group"> <div className="">
{getFormCollectionByID( <div className="govuk-button-group">
appealTypeID {getFormCollectionByID(
).PrimaryIdAttribute == appealTypeID
"pinswg_sipscase" && ).PrimaryIdAttribute ==
showReps( "pinswg_sipscase" &&
detailsObj.pinswg_consultationopen, showReps(
detailsObj.pinswg_consultationclose detailsObj.pinswg_consultationopen,
) && ( detailsObj.pinswg_consultationclose
<> ) && (
{showRepButton( <>
props {showRepButton(
.currentView props
.caseReference .currentView
.appealType .caseReference
) ? ( .appealType
<> ) ? (
<Link <>
href={{ <Link
pathname: href={{
"/myportal/representation", pathname:
query: { "/myportal/representation",
case: query: {
currentType == case:
"searchResultsObj" currentType ==
? detailsObj.pinswg_name "searchResultsObj"
: currentType ==
"watchedCases"
? casesObj.pinswg_title
: currentType ==
"directResultsObj"
? detailsObj.pinswg_name ? detailsObj.pinswg_name
: casesObj.reference : currentType ==
} "watchedCases"
}} ? casesObj.pinswg_title
className="govuk-button" : currentType ==
> "directResultsObj"
{props ? detailsObj.pinswg_name
.currentView : casesObj.reference
.caseReference }
.appealType == }}
846040002 className="govuk-button"
? t( >
"case:summary-make-consultation-label" {props
) .currentView
: t( .caseReference
"case:summary-make-representation-label" .appealType ==
)} 846040002
</Link> ? t(
"case:summary-make-consultation-label"
<a )
onClick={() => { : t(
//spinnerState(); "case:summary-make-representation-label"
router.back(); )}
}} </Link>
className="govuk-button govuk-button--secondary" </>
> ) : !isLPA &&
{t( props
"case:summary-back-button-label" .currentView
)} .caseReference
</a> .appealType ==
</> 846040004 ? (
) : !isLPA && ""
props.currentView ) : (
.caseReference <>
.appealType == <div className="govuk-grid-column-full govuk-!-padding-left-0">
846040004 ? ( <div className="govuk-button-group">
"" <p className="govuk-body">
) : ( {t(
<> "case:representation-date-passed-label",
<div className="govuk-grid-column-full govuk-!-padding-left-0"> {
<div className="govuk-button-group"> startDate:
<p className="govuk-body"> formatDates(
{t( detailsObj.pinswg_consultationopen
"case:representation-date-passed-label", ),
{ endDate:
startDate: formatDates(
formatDates( detailsObj.pinswg_consultationclose
detailsObj.pinswg_consultationopen )
), }
endDate: )}
formatDates( <br />{" "}
detailsObj.pinswg_consultationclose {t(
"case:representation-date-passed-additional-label"
)}{" "}
<Link
href={
"mailto:" +
t(
"home:login-contact-email"
) )
} }
)} >
<br />{" "} {t(
{t(
"case:representation-date-passed-additional-label"
)}{" "}
<Link
href={
"mailto:" +
t(
"home:login-contact-email" "home:login-contact-email"
) )}
} </Link>
> </p>
{t( </div>
"home:login-contact-email"
)}
</Link>
</p>
</div> </div>
</div> </>
</> )}
)} </>
</> )}
)} {(_.has(
{(_.has(
detailsObj,
"pinswg_startdate"
) ||
_.has(
detailsObj, detailsObj,
"pinswg_applicationacceptedasvalid" "pinswg_startdate"
) || ) ||
_.has( _.has(
detailsObj, detailsObj,
"pinswg_startdates" "pinswg_applicationacceptedasvalid"
)) && ) ||
showReps( _.has(
detailsObj.pinswg_startdate || detailsObj,
detailsObj.pinswg_startdates || "pinswg_startdates"
detailsObj.pinswg_applicationacceptedasvalid, )) &&
detailsObj.pinswg_finalcommentsduedate || showReps(
detailsObj.pinswg_endofrepresentationperiod detailsObj.pinswg_startdate ||
) && ( detailsObj.pinswg_startdates ||
<> detailsObj.pinswg_applicationacceptedasvalid,
{showRepButton( detailsObj.pinswg_finalcommentsduedate ||
props detailsObj.pinswg_endofrepresentationperiod
.currentView ) && (
.caseReference <>
.appealType {showRepButton(
) ? ( props
<> .currentView
<Link .caseReference
href={{ .appealType
pathname: ) ? (
"/myportal/representation", <>
query: { <Link
case: href={{
currentType == pathname:
"searchResultsObj" "/myportal/representation",
? detailsObj.ticketnumber query: {
: currentType == case:
"watchedCases" currentType ==
? casesObj.pinswg_title "searchResultsObj"
: currentType ==
"directResultsObj"
? detailsObj.ticketnumber ? detailsObj.ticketnumber
: casesObj.reference : currentType ==
} "watchedCases"
}} ? casesObj.pinswg_title
className="govuk-button" : currentType ==
> "directResultsObj"
{t( ? detailsObj.ticketnumber
"case:summary-make-representation-label" : casesObj.reference
)} }
</Link> }}
className="govuk-button"
<a >
onClick={() => { {t(
//spinnerState(); "case:summary-make-representation-label"
router.back(); )}
}} </Link>
className="govuk-button govuk-button--secondary" </>
> ) : !isLPA &&
{t( props
"case:summary-back-button-label" .currentView
)} .caseReference
</a> .appealType ==
</> 846040004 ? (
) : !isLPA && ""
props.currentView ) : (
.caseReference <>
.appealType == <div className="govuk-grid-column-full govuk-!-padding-left-0">
846040004 ? ( <div className="govuk-button-group">
"" <p className="govuk-body">
) : (
<>
<div className="govuk-grid-column-full govuk-!-padding-left-0">
<div className="govuk-button-group">
<p className="govuk-body">
{t(
"case:representation-date-passed-label",
{
startDate:
formatDates(
detailsObj.pinswg_startdate
),
endDate:
props
.currentView
.caseReference
.appealType ==
846040019
? formatDates(
detailsObj.pinswg_statementduedate
)
: formatDates(
detailsObj.pinswg_finalcommentsduedate
)
}
)}
<br />{" "}
{t(
"case:representation-date-passed-additional-label"
)}{" "}
<Link
href={
"mailto:" +
t(
"home:login-contact-email"
)
}
>
{t( {t(
"home:login-contact-email" "case:representation-date-passed-label",
{
startDate:
formatDates(
detailsObj.pinswg_startdate
),
endDate:
props
.currentView
.caseReference
.appealType ==
846040019
? formatDates(
detailsObj.pinswg_statementduedate
)
: formatDates(
detailsObj.pinswg_finalcommentsduedate
)
}
)} )}
</Link> <br />{" "}
</p> {t(
"case:representation-date-passed-additional-label"
)}{" "}
<Link
href={
"mailto:" +
t(
"home:login-contact-email"
)
}
>
{t(
"home:login-contact-email"
)}
</Link>
</p>
</div>
</div> </div>
</div> </>
</> )}
)} </>
</> )}
)}
<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>
+58 -68
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,34 +364,24 @@ 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={{
(router.locale == "cy" pathname:
? myportal == true (router.locale == "cy"
? "/fymhorth/achos" ? myportal == true
: "/achos" ? "/fymhorth/achos"
: myportal == true : "/achos"
? "/myportal/case" : myportal == true
: "/case") + ? "/myportal/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(
@@ -424,13 +414,13 @@ const SearchResults = (props) => {
) < 0 ) < 0
? detailsObj.pinswg_projectlocation ? detailsObj.pinswg_projectlocation
: router.locale == : router.locale ==
"cy" "cy"
? detailsObj.pinswg_projectlocation.split( ? detailsObj.pinswg_projectlocation.split(
";" ";"
)[1] )[1]
: detailsObj.pinswg_projectlocation.split( : detailsObj.pinswg_projectlocation.split(
";" ";"
)[0] )[0]
: "", : "",
highlightQuery highlightQuery
) )
@@ -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,
}; };
+73 -65
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,25 +389,32 @@ 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={{
(router.locale == "cy" pathname:
? myportal == true (router.locale == "cy"
? "/fymhorth/achos" ? myportal == true
: "/achos" ? "/fymhorth/achos"
: myportal == true : "/achos"
? "/myportal/case" : myportal == true
: "/case") + ? "/myportal/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({
@@ -428,11 +436,11 @@ const SearchResults = (props) => {
) )
? detailsObj.pinswg_speacialistcaseprocess ? detailsObj.pinswg_speacialistcaseprocess
: detailsObj.hasOwnProperty( : detailsObj.hasOwnProperty(
"pinswg_specialistcaseprocess" "pinswg_specialistcaseprocess"
) )
? detailsObj.pinswg_specialistcaseprocess ? detailsObj.pinswg_specialistcaseprocess
: "", : ""
}); }));
}} }}
> >
<span className="results-visually-hidden"> <span className="results-visually-hidden">
@@ -486,12 +494,12 @@ const SearchResults = (props) => {
) < 0 ) < 0
? detailsObj.pinswg_projectlocation ? detailsObj.pinswg_projectlocation
: router.locale == "cy" : router.locale == "cy"
? detailsObj.pinswg_projectlocation.split( ? detailsObj.pinswg_projectlocation.split(
";" ";"
)[1] )[1]
: detailsObj.pinswg_projectlocation.split( : detailsObj.pinswg_projectlocation.split(
";" ";"
)[0] )[0]
: "" : ""
: // : hasValidKey( : // : hasValidKey(
// item, // item,
@@ -585,12 +593,12 @@ 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"
] ]
: ""} : ""}
</dd> </dd>
<dd className="govuk-summary-list__value govuk-!-font-size-16"> <dd className="govuk-summary-list__value govuk-!-font-size-16">
<span className="results-visually-hidden"> <span className="results-visually-hidden">
@@ -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,
}; };