16951 mail notification subscribe
This commit is contained in:
@@ -110,23 +110,24 @@ const SearchResults = (props) => {
|
||||
"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);
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
// );
|
||||
// });
|
||||
createWatchedCases(updateBody)
|
||||
.then((data) => data)
|
||||
.then(() => {
|
||||
getWatchedCasesProxy(props.accountDetails.loggedinUserId).then(
|
||||
(data) => {
|
||||
setWatchedCases(data),
|
||||
getDetailsProxy(data, "myWatchedCases").then(
|
||||
(data) => {
|
||||
setWatchedCasesDetails(data);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const isWatchedCase = (whichIncident) => {
|
||||
@@ -143,6 +144,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 isEmailNotifications = (whichIncident) => {
|
||||
let isWatched = jsonpath({
|
||||
path:
|
||||
@@ -643,28 +657,57 @@ const SearchResults = (props) => {
|
||||
<span className="eye"></span>
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
className="govuk-summary-list__actionLink mailLink"
|
||||
title="Email about changes"
|
||||
onClick={() => {
|
||||
confirm(
|
||||
" Do you want to be sent email updates for " +
|
||||
item.title +
|
||||
"?"
|
||||
) &&
|
||||
selectEmailNotifications(
|
||||
props.accountDetails
|
||||
.accountDetails
|
||||
.emailaddress1,
|
||||
props.accountDetails
|
||||
.loggedinUserId,
|
||||
item.incidentid,
|
||||
item.pinswg_appealcasetype
|
||||
);
|
||||
}}
|
||||
>
|
||||
<span className="mailicon icon"></span>
|
||||
</button>
|
||||
{isEmailSignUp(item.incidentid)
|
||||
.length >
|
||||
0 ==
|
||||
true ? (
|
||||
<button
|
||||
className="govuk-summary-list__actionLink mailLink watched_link"
|
||||
title="Unsubscribe to email updates"
|
||||
onClick={() => {
|
||||
confirm(
|
||||
" Do you want to unsubscribe to email updates for " +
|
||||
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(
|
||||
" Do you want to be sent email updates for " +
|
||||
item.title +
|
||||
"?"
|
||||
) &&
|
||||
selectEmailNotifications(
|
||||
props
|
||||
.accountDetails
|
||||
.accountDetails
|
||||
.emailaddress1,
|
||||
props
|
||||
.accountDetails
|
||||
.loggedinUserId,
|
||||
item.incidentid,
|
||||
item.pinswg_appealcasetype
|
||||
);
|
||||
}}
|
||||
>
|
||||
<span className="mailicon icon"></span>
|
||||
</button>
|
||||
)}
|
||||
</dd>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user