17025 unsub fixes

This commit is contained in:
2025-06-09 14:12:44 +01:00
parent 3d897e6b26
commit f11aa09412
5 changed files with 236 additions and 53 deletions
+170 -20
View File
@@ -124,6 +124,36 @@ const CaseSummary = (props) => {
setCaseInvolvment(incidentid, loggedInUser);
};
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:
@@ -137,6 +167,19 @@ const CaseSummary = (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" &&
@@ -942,13 +985,129 @@ const CaseSummary = (props) => {
.incidentid
).length >
0 ==
true ? (
<>
<button
className="govuk-link watchCase"
onClick={() => {
confirm(
t(
"case:you-have-stopped-watching-label"
) +
props
.currentView
.caseReference
.currentReference +
"?"
) &&
deleteItem(
isWatchedCase(
props
.currentView
.caseReference
.incidentid
)[0]
.pinswg_watchlistid,
"watchedCases"
),
setCurrentView(
{
"viewName":
"Watched Cases",
"viewKey":
"watchedCases",
}
);
setCurrentReference(
{
"ticketnumber":
props
.currentView
.caseReference
.currentReference,
"currentReference":
props
.currentView
.caseReference
.currentReference,
"currentType":
"searchResultsObj",
"incidentid":
props
.currentView
.caseReference
.incidentid,
"appealType":
props
.currentView
.caseReference
.appealType,
"showMap":
showMap,
}
);
}}
title={t(
"case:stop-watching-case-link"
)}
>
{t(
"case:stop-watching-case-link"
)}{" "}
</button>
</>
) : (
<>
<button
className="govuk-link watchCase"
onClick={() => {
confirm(
t(
"case:you-are-watching-label"
) +
" " +
props
.currentView
.caseReference
.currentReference +
"?"
) &&
selectWatchedCase(
props
.accountDetails
.loggedinUserId,
props
.currentView
.caseReference
.incidentid,
props
.currentView
.caseReference
.appealType
);
}}
>
{t(
"case:watch-this-case-link"
)}
</button>
</>
))}
{session &&
(isEmailSignUp(
props.currentView
.caseReference
.incidentid
).length >
0 ==
true ? (
<button
className="govuk-link watchCase"
onClick={() => {
confirm(
t(
"case:you-have-stopped-watching-label"
"case:summary-unsubscribe-mail-label"
) +
props
.currentView
@@ -957,7 +1116,7 @@ const CaseSummary = (props) => {
"?"
) &&
deleteItem(
isWatchedCase(
isEmailSignUp(
props
.currentView
.caseReference
@@ -1005,11 +1164,11 @@ const CaseSummary = (props) => {
);
}}
title={t(
"case:stop-watching-case-link"
"case:stop-sending-email-notifications"
)}
>
{t(
"case:stop-watching-case-link"
"case:stop-sending-email-notifications"
)}{" "}
</button>
) : (
@@ -1019,7 +1178,7 @@ const CaseSummary = (props) => {
onClick={() => {
confirm(
t(
"case:you-are-watching-label"
"case:summary-subscribe-mail-label"
) +
" " +
props
@@ -1028,7 +1187,11 @@ const CaseSummary = (props) => {
.currentReference +
"?"
) &&
selectWatchedCase(
selectEmailNotifications(
props
.accountDetails
.accountDetails
.emailaddress1,
props
.accountDetails
.loggedinUserId,
@@ -1044,15 +1207,9 @@ const CaseSummary = (props) => {
}}
>
{t(
"case:watch-this-case-link"
"case:send-email-notifications"
)}
</button>
<button className="govuk-link mailNotification">
Send me
email
updates
</button>
{/* <button
onClick={
handleOpenModal
@@ -1062,7 +1219,6 @@ const CaseSummary = (props) => {
</button> */}
</>
))}
{!session && (
<>
<button
@@ -1111,12 +1267,6 @@ const CaseSummary = (props) => {
"case:watch-this-case-link"
)}
</button>
<button className="govuk-link mailNotification">
Send me email
updates
</button>
{/* <button
onClick={handleOpenModal}
>