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}
>
+3 -1
View File
@@ -666,7 +666,9 @@ const SearchResults = (props) => {
title="Unsubscribe to email updates"
onClick={() => {
confirm(
" Do you want to unsubscribe to email updates for " +
t(
"case:summary-unsubscribe-mail-label"
) +
item.title +
"?"
) &&
+5 -1
View File
@@ -120,5 +120,9 @@
"event-start-date-label": "Dyddiad cychwyn ",
"event-end-date-label": "Dyddiad gorffen ",
"event-type-of-event-label": "Math o ddigwyddiad",
"notice-label": "Hysbysiad"
"notice-label": "Hysbysiad",
"summary-subscribe-mail-label": "Ydych chi eisiau derbyn diweddariadau e-bost ar gyfer ",
"summary-unsubscribe-mail-label": "Ydych chi eisiau dad-danysgrifio i ddiweddariadau e-bost ar gyfer ",
"send-email-notifications": "Anfon hysbysiadau e-bost am ddiweddariadau i'r achos hwn",
"stop-sending-email-notifications": "Stopio anfon diweddariadau e-bost"
}
+5 -1
View File
@@ -121,5 +121,9 @@
"event-start-date-label": "Start date",
"event-end-date-label": "End date",
"event-type-of-event-label": "Type of event",
"notice-label": "Notice"
"notice-label": "Notice",
"summary-subscribe-mail-label": "Do you want to be sent email updates for ",
"summary-unsubscribe-mail-label": "Do you want to unsubscribe to email updates for ",
"send-email-notifications": "Send email notifications for updates to this case",
"stop-sending-email-notifications": "Stop sending email updates"
}
+53 -30
View File
@@ -255,41 +255,41 @@ export const getServerSideProps = wrapper.getServerSideProps(
);
break;
case "watchedCases":
const watchedCases = await getWatchedCases(
loggedInUser
);
// const watchedCases = await getWatchedCases(
// loggedInUser
// );
let showWatchedCases = (submittedArr) => {
const required = submittedArr.value.filter(
(el) => {
return (
el.pinswg_representationsubmitted ==
null
);
}
);
// 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,
});
};
// let newObj = {};
// return Object.assign(newObj, {
// "@odata.count": required.length,
// "value": required,
// });
// };
let filteredWatchedCases =
showWatchedCases(watchedCases);
// let filteredWatchedCases =
// showWatchedCases(watchedCases);
const watchedCasesDetails = await getDetails(
filteredWatchedCases,
"myWatchedCases"
);
// const watchedCasesDetails = await getDetails(
// filteredWatchedCases,
// "myWatchedCases"
// );
store.dispatch(
setWatchedCases(filteredWatchedCases)
);
store.dispatch(
setWatchedCasesDetails(watchedCasesDetails)
);
// store.dispatch(
// setWatchedCases(filteredWatchedCases)
// );
// store.dispatch(
// setWatchedCasesDetails(watchedCasesDetails)
// );
store.dispatch(
setCurrentView({
@@ -346,6 +346,29 @@ export const getServerSideProps = wrapper.getServerSideProps(
// code block
}
}
const watchedCases = await getWatchedCases(loggedInUser);
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,
});
};
let filteredWatchedCases = showWatchedCases(watchedCases);
const watchedCasesDetails = await getDetails(
filteredWatchedCases,
"myWatchedCases"
);
store.dispatch(setWatchedCases(filteredWatchedCases));
store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
store.dispatch(setSearchResults(searchResultsObj));
store.dispatch(setSearchDetails(searchDetailsObj));
store.dispatch(