17025 unsub issues

This commit is contained in:
2025-06-10 11:25:32 +01:00
parent 5dee64dfec
commit 193da6af2f
9 changed files with 412 additions and 25 deletions
+58 -5
View File
@@ -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"
)}
</button>{" "}
<button
className="govuk-link watchCase"
onClick={() => {
confirm(
t(
"case:summary-subscribe-mail-label"
) +
" " +
props
.currentView
.caseReference
.currentReference +
"?"
) &&
setCookie(
null,
"pedwWatchCase",
currentType ==
"searchResultsObj"
? detailsObj.pinswg_name
: currentType ==
"directResultsObj"
? casesObj.title
: casesObj.reference,
{
path: "/",
expires:
expDate,
}
),
signIn();
}}
>
{t(
"case:send-email-notifications"
)}
</button>
{/* <button
onClick={handleOpenModal}
>
Open Modal
</button> */}
</>
)}
</div>
+31 -8
View File
@@ -759,9 +759,7 @@ const ViewAllResults = (props) => {
style={{ display: "flex", flexDirection: "column" }}
>
<button
title={t(
"case:do-you-want-to-delete-case-label"
)}
title={t("case:stop-watching-case-link")}
className=" govuk-summary-list__actionLink watched_link"
onClick={() => {
confirm(
@@ -778,15 +776,17 @@ const ViewAllResults = (props) => {
);
}}
>
&mdash;
<span className="eye"></span>
</button>
{item.pinswg_emailnotifications == true ? (
<button
className="govuk-summary-list__actionLink mailLink watched_link"
title="Unsubscribe to email updates"
title={t("common:unsubscribe-title-label")}
onClick={() => {
confirm(
" Do you want to unsubscribe to email updates for " +
t(
"case:summary-unsubscribe-mail-label"
) +
item.pinswg_title +
"?"
) &&
@@ -807,10 +807,12 @@ const ViewAllResults = (props) => {
) : (
<button
className="govuk-summary-list__actionLink mailLink"
title="Email about changes"
title={t("common:subscribe-title-label")}
onClick={() => {
confirm(
" Do you want to be sent email updates for " +
t(
"case:summary-subscribe-mail-label"
) +
item.pinswg_title +
"?"
) &&
@@ -937,6 +939,27 @@ const ViewAllResults = (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) => {
+147
View File
@@ -94,6 +94,36 @@ const SearchResults = (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:
@@ -107,6 +137,19 @@ const SearchResults = (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" &&
@@ -116,6 +159,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) => {
@@ -594,6 +658,61 @@ const SearchResults = (props) => {
<span className="eye"></span>
</button>
)}
{isEmailSignUp(item.incidentid)
.length >
0 ==
true ? (
<button
className="govuk-summary-list__actionLink mailLink watched_link"
title="Unsubscribe to email updates"
onClick={() => {
confirm(
t(
"case:summary-unsubscribe-mail-label"
) +
item.title +
"?"
) &&
deleteItem(
isEmailSignUp(
item.incidentid
)[0]
.pinswg_watchlistid,
"watchedCases"
);
}}
>
<span className="mailicon icon"></span>
</button>
) : (
<button
className="govuk-summary-list__actionLink mailLink"
title="Email about changes"
onClick={() => {
confirm(
t(
"case:summary-subscribe-mail-label"
) +
item.title +
"?"
) &&
selectEmailNotifications(
props
.accountDetails
.accountDetails
.emailaddress1,
props
.accountDetails
.loggedinUserId,
item.incidentid,
item.pinswg_appealcasetype
);
}}
>
<span className="mailicon icon"></span>
</button>
)}
</dd>
)}
@@ -639,6 +758,34 @@ const SearchResults = (props) => {
>
<span className="eye"></span>
</button>
<button
className="govuk-summary-list__actionLink mailLink"
title={t(
"common:subscribe-title-label"
)}
onClick={() => {
confirm(
t(
"case:summary-subscribe-mail-label"
) +
item.pinswg_name +
"?"
) &&
signIn(undefined, {
callbackUrl:
"/myportal/addresssearchresults?" +
new URLSearchParams(
searchString
) +
"&toWatch=" +
item.incidentid +
"_" +
item.pinswg_appealcasetype,
});
}}
>
<span className="mailicon icon"></span>
</button>
</dd>
)}
</div>
+132 -5
View File
@@ -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 ? (
<span
<button
className="govuk-summary-list__actionLink watched_link"
onClick={() => {
confirm(
@@ -590,9 +654,9 @@ const DNSSearchResults = (props) => {
)}
>
<span className="eye"></span>
</span>
</button>
) : (
<span
<button
className="govuk-summary-list__actionLink watchLink"
onClick={() => {
confirm(
@@ -613,7 +677,61 @@ const DNSSearchResults = (props) => {
)}
>
<span className="eye"></span>
</span>
</button>
)}
{isEmailSignUp(item.incidentid)
.length >
0 ==
true ? (
<button
className="govuk-summary-list__actionLink mailLink watched_link"
title="Unsubscribe to email updates"
onClick={() => {
confirm(
t(
"case:summary-unsubscribe-mail-label"
) +
item.title +
"?"
) &&
deleteItem(
isEmailSignUp(
item.incidentid
)[0]
.pinswg_watchlistid,
"watchedCases"
);
}}
>
<span className="mailicon icon"></span>
</button>
) : (
<button
className="govuk-summary-list__actionLink mailLink"
title="Email about changes"
onClick={() => {
confirm(
t(
"case:summary-subscribe-mail-label"
) +
item.title +
"?"
) &&
selectEmailNotifications(
props
.accountDetails
.emailaddress1,
props
.accountDetails
.loggedinUserId,
item.incidentid,
item.pinswg_appealcasetype
);
}}
>
<span className="mailicon icon"></span>
</button>
)}
</dd>
)}
@@ -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);
+30 -3
View File
@@ -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) => {
</button>
<button
className="govuk-summary-list__actionLink mailLink"
title="Email about changes"
title={t(
"common:subscribe-title-label"
)}
onClick={() => {
confirm(
" Do you want to be sent email updates for " +
t(
"case:summary-subscribe-mail-label"
) +
item.title +
"?"
) &&
+7 -2
View File
@@ -22,7 +22,12 @@ module.exports = {
"/myportal/searchresults": ["search", "myportal", "case"],
"/myportal/case": ["case"],
"/myportal/case/[ticketnumber]": ["case"],
"/myportal/dnsapplications": ["search", "dnsCommon", "dnsApplications"],
"/myportal/dnsapplications": [
"search",
"dnsCommon",
"dnsApplications",
"case",
],
"/myportal/dnsdetails": [
"case",
"search",
@@ -61,7 +66,7 @@ module.exports = {
"/dns": ["dnsCommon", "dnsHome"],
"/dns/applications": ["dnsCommon", "dnsApplications"],
"/dns/application-view": ["dnsCommon", "dnsApplicationView"],
"/dnsapplications": ["search", "dnsCommon", "dnsApplications"],
"/dnsapplications": ["search", "dnsCommon", "dnsApplications", "case"],
"/dnsdetails": ["case", "search", "dnsCommon", "dnsApplications"],
"/help/cookies": ["common", "cookies"],
"/account/register": ["common", "account"],
+3 -1
View File
@@ -113,5 +113,7 @@
"contact-us-select-ceq": "Ymholiad Digwyddiadau Gwaith Achos",
"contact-us-select-other": "Unrhyw Ymholiadau Eraill",
"contact-us-select-postdec": "Ar ôl Penderfyniad",
"contact-us-select-comp": "Cwynion/Canmoliaethau"
"contact-us-select-comp": "Cwynion/Canmoliaethau",
"unsubscribe-title-label": "Dad-danysgrifio i ddiweddariadau e-bost",
"subscribe-title-label": "Tanysgrifio i ddiweddariadau e-bost"
}
+3 -1
View File
@@ -113,5 +113,7 @@
"contact-us-select-ceq": "Casework Events Query",
"contact-us-select-other": "Any Other Enquiries",
"contact-us-select-postdec": "Post Decision",
"contact-us-select-comp": "Complaints/Complements"
"contact-us-select-comp": "Complaints/Complements",
"unsubscribe-title-label": "Unsubscribe to email updates",
"subscribe-title-label": "Subscribe to email updates"
}
+1
View File
@@ -121,6 +121,7 @@ const Home = (props) => {
<div className="govuk-width-container">
<Breadcrumbs slug={appealtypes} />
<ServiceBanner props={props} />
<DNSSearchResults
showMap={showMap}
searchString="DNS"