16951 mail notification subscribe

This commit is contained in:
2025-05-30 10:16:21 +01:00
parent eb020b014d
commit 2cfb06db2a
2 changed files with 90 additions and 36 deletions
+79 -36
View File
@@ -110,23 +110,24 @@ 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,
}; };
console.log("Email signed up"); console.log("Email signed up");
// createWatchedCases(updateBody) createWatchedCases(updateBody)
// .then((data) => data) .then((data) => data)
// .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);
// } }
// ); );
// } }
// ); );
// }); });
}; };
const isWatchedCase = (whichIncident) => { const isWatchedCase = (whichIncident) => {
@@ -143,6 +144,19 @@ const SearchResults = (props) => {
return isWatched; 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) => { const isEmailNotifications = (whichIncident) => {
let isWatched = jsonpath({ let isWatched = jsonpath({
path: path:
@@ -643,28 +657,57 @@ const SearchResults = (props) => {
<span className="eye"></span> <span className="eye"></span>
</button> </button>
)} )}
<button {isEmailSignUp(item.incidentid)
className="govuk-summary-list__actionLink mailLink" .length >
title="Email about changes" 0 ==
onClick={() => { true ? (
confirm( <button
" Do you want to be sent email updates for " + className="govuk-summary-list__actionLink mailLink watched_link"
item.title + title="Unsubscribe to email updates"
"?" onClick={() => {
) && confirm(
selectEmailNotifications( " Do you want to unsubscribe to email updates for " +
props.accountDetails item.title +
.accountDetails "?"
.emailaddress1, ) &&
props.accountDetails deleteItem(
.loggedinUserId, isEmailSignUp(
item.incidentid, item.incidentid
item.pinswg_appealcasetype )[0]
); .pinswg_watchlistid,
}}
> "watchedCases"
<span className="mailicon icon"></span> );
</button> }}
>
<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> </dd>
)} )}
+11
View File
@@ -2403,7 +2403,18 @@ ul#sharePageLinks.active {
} }
} }
dd.govuk-summary-list__value.govuk-\!-font-size-14.govuk-summary-list__action {
display: flex;
flex-direction: column;
border: none
}
.govuk-summary-list__actionLink { .govuk-summary-list__actionLink {
border: 1px solid $red; border: 1px solid $red;
padding: 5px; padding: 5px;
height: 20px; height: 20px;