17025 unsub issues
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user