From 193da6af2f014f6ec69d7d8a3646f96fc7e1dba5 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Tue, 10 Jun 2025 11:25:32 +0100 Subject: [PATCH 1/2] 17025 unsub issues --- components/case/summary.js | 63 +++++++++- components/myportal/viewall.js | 39 ++++-- components/search/addresssearchresults.js | 147 ++++++++++++++++++++++ components/search/dnssearchresults.js | 137 +++++++++++++++++++- components/search/searchresults.js | 33 ++++- i18n.js | 9 +- locales/cy/common.json | 4 +- locales/en/common.json | 4 +- pages/myportal/dnsapplications.js | 1 + 9 files changed, 412 insertions(+), 25 deletions(-) diff --git a/components/case/summary.js b/components/case/summary.js index 3a23f05c..35a485b8 100644 --- a/components/case/summary.js +++ b/components/case/summary.js @@ -187,6 +187,27 @@ const CaseSummary = (props) => { .then((data) => data) .then(() => { getWatchedCasesProxy(cookies.pinsUser).then((data) => { + let showWatchedCases = (submittedArr) => { + const required = submittedArr.value.filter((el) => { + return ( + el.pinswg_representationsubmitted == null + ); + }); + + let newObj = {}; + return Object.assign(newObj, { + "@odata.count": required.length, + "value": required, + }); + }; + + data = showWatchedCases(data); + + data.value.sort(function compare(a, b) { + var dateA = new Date(a.createdon); + var dateB = new Date(b.createdon); + return dateB - dateA; + }); setWatchedCases(data), getDetailsProxy(data, "myWatchedCases").then( (data) => { @@ -1266,12 +1287,44 @@ const CaseSummary = (props) => { {t( "case:watch-this-case-link" )} + {" "} + - {/* */} )} diff --git a/components/myportal/viewall.js b/components/myportal/viewall.js index 43a2bbfb..0a39c4bc 100644 --- a/components/myportal/viewall.js +++ b/components/myportal/viewall.js @@ -759,9 +759,7 @@ const ViewAllResults = (props) => { style={{ display: "flex", flexDirection: "column" }} > {item.pinswg_emailnotifications == true ? ( )} + {isEmailSignUp(item.incidentid) + .length > + 0 == + true ? ( + + ) : ( + + )} )} @@ -639,6 +758,34 @@ const SearchResults = (props) => { > + )} diff --git a/components/search/dnssearchresults.js b/components/search/dnssearchresults.js index 01708b5a..45c5b090 100644 --- a/components/search/dnssearchresults.js +++ b/components/search/dnssearchresults.js @@ -170,6 +170,36 @@ const DNSSearchResults = (props) => { }); }; + const selectEmailNotifications = ( + emailaddress, + loggedInUser, + incidentID, + appealType + ) => { + let updateBody = { + "pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")", + "pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")", + "pinswg_appealcasetype": +appealType, + "pinswg_emailnotifications": true, + }; + + console.log("Email signed up"); + createWatchedCases(updateBody) + .then((data) => data) + .then(() => { + getWatchedCasesProxy(props.accountDetails.loggedinUserId).then( + (data) => { + setWatchedCases(data), + getDetailsProxy(data, "myWatchedCases").then( + (data) => { + setWatchedCasesDetails(data); + } + ); + } + ); + }); + }; + const isWatchedCase = (whichIncident) => { let isWatched = jsonpath({ path: @@ -183,6 +213,19 @@ const DNSSearchResults = (props) => { return isWatched; }; + const isEmailSignUp = (whichIncident) => { + let isEmail = jsonpath({ + path: + "$..value[?(@ && @._pinswg_watchedcase_value=='" + + whichIncident + + "' && @.pinswg_emailnotifications==true)]", + + json: watchedCases, + eval: true, + }); + return isEmail; + }; + const deleteItem = (caseID, topThreeType) => { let cookies = parseCookies(); topThreeType == "watchedCases" && @@ -190,6 +233,27 @@ const DNSSearchResults = (props) => { .then((data) => data) .then(() => { getWatchedCasesProxy(cookies.pinsUser).then((data) => { + let showWatchedCases = (submittedArr) => { + const required = submittedArr.value.filter((el) => { + return ( + el.pinswg_representationsubmitted == null + ); + }); + + let newObj = {}; + return Object.assign(newObj, { + "@odata.count": required.length, + "value": required, + }); + }; + + data = showWatchedCases(data); + + data.value.sort(function compare(a, b) { + var dateA = new Date(a.createdon); + var dateB = new Date(b.createdon); + return dateB - dateA; + }); setWatchedCases(data), getDetailsProxy(data, "myWatchedCases").then( (data) => { @@ -566,7 +630,7 @@ const DNSSearchResults = (props) => { .length > 0 == true ? ( - { confirm( @@ -590,9 +654,9 @@ const DNSSearchResults = (props) => { )} > - + ) : ( - { confirm( @@ -613,7 +677,61 @@ const DNSSearchResults = (props) => { )} > - + + )} + {isEmailSignUp(item.incidentid) + .length > + 0 == + true ? ( + + ) : ( + )} )} @@ -868,4 +986,13 @@ const mapDispatchToProps = (dispatch) => { }; }; -export default connect(null, mapDispatchToProps)(DNSSearchResults); +const mapStateToProps = (state) => { + return { + // currentView: state.currentView, + accountDetails: state.accountDetails, + // search: state.search, + // searchResultsObj: state.searchResultsObj, + }; +}; + +export default connect(mapStateToProps, mapDispatchToProps)(DNSSearchResults); diff --git a/components/search/searchresults.js b/components/search/searchresults.js index 59448d2d..b8803fec 100644 --- a/components/search/searchresults.js +++ b/components/search/searchresults.js @@ -180,6 +180,27 @@ const SearchResults = (props) => { getWatchedCasesProxy( props.accountDetails.loggedinUserId ).then((data) => { + let showWatchedCases = (submittedArr) => { + const required = submittedArr.value.filter((el) => { + return ( + el.pinswg_representationsubmitted == null + ); + }); + + let newObj = {}; + return Object.assign(newObj, { + "@odata.count": required.length, + "value": required, + }); + }; + + data = showWatchedCases(data); + + data.value.sort(function compare(a, b) { + var dateA = new Date(a.createdon); + var dateB = new Date(b.createdon); + return dateB - dateA; + }); setWatchedCases(data), getDetailsProxy(data, "myWatchedCases").then( (data) => { @@ -690,7 +711,9 @@ const SearchResults = (props) => { title="Email about changes" onClick={() => { confirm( - " Do you want to be sent email updates for " + + t( + "case:summary-subscribe-mail-label" + ) + item.title + "?" ) && @@ -754,10 +777,14 @@ const SearchResults = (props) => {