Merged PR 1659: 17025 unsub fixes
17025 unsub fixes Related work items: #17025
This commit is contained in:
+170
-20
@@ -124,6 +124,36 @@ const CaseSummary = (props) => {
|
|||||||
setCaseInvolvment(incidentid, loggedInUser);
|
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) => {
|
const isWatchedCase = (whichIncident) => {
|
||||||
let isWatched = jsonpath({
|
let isWatched = jsonpath({
|
||||||
path:
|
path:
|
||||||
@@ -137,6 +167,19 @@ const CaseSummary = (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 deleteItem = (caseID, topThreeType) => {
|
const deleteItem = (caseID, topThreeType) => {
|
||||||
let cookies = parseCookies();
|
let cookies = parseCookies();
|
||||||
topThreeType == "watchedCases" &&
|
topThreeType == "watchedCases" &&
|
||||||
@@ -942,13 +985,129 @@ const CaseSummary = (props) => {
|
|||||||
.incidentid
|
.incidentid
|
||||||
).length >
|
).length >
|
||||||
0 ==
|
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 ? (
|
true ? (
|
||||||
<button
|
<button
|
||||||
className="govuk-link watchCase"
|
className="govuk-link watchCase"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
confirm(
|
confirm(
|
||||||
t(
|
t(
|
||||||
"case:you-have-stopped-watching-label"
|
"case:summary-unsubscribe-mail-label"
|
||||||
) +
|
) +
|
||||||
props
|
props
|
||||||
.currentView
|
.currentView
|
||||||
@@ -957,7 +1116,7 @@ const CaseSummary = (props) => {
|
|||||||
"?"
|
"?"
|
||||||
) &&
|
) &&
|
||||||
deleteItem(
|
deleteItem(
|
||||||
isWatchedCase(
|
isEmailSignUp(
|
||||||
props
|
props
|
||||||
.currentView
|
.currentView
|
||||||
.caseReference
|
.caseReference
|
||||||
@@ -1005,11 +1164,11 @@ const CaseSummary = (props) => {
|
|||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
title={t(
|
title={t(
|
||||||
"case:stop-watching-case-link"
|
"case:stop-sending-email-notifications"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{t(
|
{t(
|
||||||
"case:stop-watching-case-link"
|
"case:stop-sending-email-notifications"
|
||||||
)}{" "}
|
)}{" "}
|
||||||
</button>
|
</button>
|
||||||
) : (
|
) : (
|
||||||
@@ -1019,7 +1178,7 @@ const CaseSummary = (props) => {
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
confirm(
|
confirm(
|
||||||
t(
|
t(
|
||||||
"case:you-are-watching-label"
|
"case:summary-subscribe-mail-label"
|
||||||
) +
|
) +
|
||||||
" " +
|
" " +
|
||||||
props
|
props
|
||||||
@@ -1028,7 +1187,11 @@ const CaseSummary = (props) => {
|
|||||||
.currentReference +
|
.currentReference +
|
||||||
"?"
|
"?"
|
||||||
) &&
|
) &&
|
||||||
selectWatchedCase(
|
selectEmailNotifications(
|
||||||
|
props
|
||||||
|
.accountDetails
|
||||||
|
.accountDetails
|
||||||
|
.emailaddress1,
|
||||||
props
|
props
|
||||||
.accountDetails
|
.accountDetails
|
||||||
.loggedinUserId,
|
.loggedinUserId,
|
||||||
@@ -1044,15 +1207,9 @@ const CaseSummary = (props) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t(
|
{t(
|
||||||
"case:watch-this-case-link"
|
"case:send-email-notifications"
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
<button className="govuk-link mailNotification">
|
|
||||||
Send me
|
|
||||||
email
|
|
||||||
updates
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{/* <button
|
{/* <button
|
||||||
onClick={
|
onClick={
|
||||||
handleOpenModal
|
handleOpenModal
|
||||||
@@ -1062,7 +1219,6 @@ const CaseSummary = (props) => {
|
|||||||
</button> */}
|
</button> */}
|
||||||
</>
|
</>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{!session && (
|
{!session && (
|
||||||
<>
|
<>
|
||||||
<button
|
<button
|
||||||
@@ -1111,12 +1267,6 @@ const CaseSummary = (props) => {
|
|||||||
"case:watch-this-case-link"
|
"case:watch-this-case-link"
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button className="govuk-link mailNotification">
|
|
||||||
Send me email
|
|
||||||
updates
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{/* <button
|
{/* <button
|
||||||
onClick={handleOpenModal}
|
onClick={handleOpenModal}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -666,7 +666,9 @@ const SearchResults = (props) => {
|
|||||||
title="Unsubscribe to email updates"
|
title="Unsubscribe to email updates"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
confirm(
|
confirm(
|
||||||
" Do you want to unsubscribe to email updates for " +
|
t(
|
||||||
|
"case:summary-unsubscribe-mail-label"
|
||||||
|
) +
|
||||||
item.title +
|
item.title +
|
||||||
"?"
|
"?"
|
||||||
) &&
|
) &&
|
||||||
|
|||||||
@@ -120,5 +120,9 @@
|
|||||||
"event-start-date-label": "Dyddiad cychwyn ",
|
"event-start-date-label": "Dyddiad cychwyn ",
|
||||||
"event-end-date-label": "Dyddiad gorffen ",
|
"event-end-date-label": "Dyddiad gorffen ",
|
||||||
"event-type-of-event-label": "Math o ddigwyddiad",
|
"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"
|
||||||
}
|
}
|
||||||
@@ -121,5 +121,9 @@
|
|||||||
"event-start-date-label": "Start date",
|
"event-start-date-label": "Start date",
|
||||||
"event-end-date-label": "End date",
|
"event-end-date-label": "End date",
|
||||||
"event-type-of-event-label": "Type of event",
|
"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"
|
||||||
}
|
}
|
||||||
@@ -255,41 +255,41 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case "watchedCases":
|
case "watchedCases":
|
||||||
const watchedCases = await getWatchedCases(
|
// const watchedCases = await getWatchedCases(
|
||||||
loggedInUser
|
// loggedInUser
|
||||||
);
|
// );
|
||||||
|
|
||||||
let showWatchedCases = (submittedArr) => {
|
// let showWatchedCases = (submittedArr) => {
|
||||||
const required = submittedArr.value.filter(
|
// const required = submittedArr.value.filter(
|
||||||
(el) => {
|
// (el) => {
|
||||||
return (
|
// return (
|
||||||
el.pinswg_representationsubmitted ==
|
// el.pinswg_representationsubmitted ==
|
||||||
null
|
// null
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
|
|
||||||
let newObj = {};
|
// let newObj = {};
|
||||||
return Object.assign(newObj, {
|
// return Object.assign(newObj, {
|
||||||
"@odata.count": required.length,
|
// "@odata.count": required.length,
|
||||||
"value": required,
|
// "value": required,
|
||||||
});
|
// });
|
||||||
};
|
// };
|
||||||
|
|
||||||
let filteredWatchedCases =
|
// let filteredWatchedCases =
|
||||||
showWatchedCases(watchedCases);
|
// showWatchedCases(watchedCases);
|
||||||
|
|
||||||
const watchedCasesDetails = await getDetails(
|
// const watchedCasesDetails = await getDetails(
|
||||||
filteredWatchedCases,
|
// filteredWatchedCases,
|
||||||
"myWatchedCases"
|
// "myWatchedCases"
|
||||||
);
|
// );
|
||||||
|
|
||||||
store.dispatch(
|
// store.dispatch(
|
||||||
setWatchedCases(filteredWatchedCases)
|
// setWatchedCases(filteredWatchedCases)
|
||||||
);
|
// );
|
||||||
store.dispatch(
|
// store.dispatch(
|
||||||
setWatchedCasesDetails(watchedCasesDetails)
|
// setWatchedCasesDetails(watchedCasesDetails)
|
||||||
);
|
// );
|
||||||
|
|
||||||
store.dispatch(
|
store.dispatch(
|
||||||
setCurrentView({
|
setCurrentView({
|
||||||
@@ -346,6 +346,29 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
// code block
|
// 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(setSearchResults(searchResultsObj));
|
||||||
store.dispatch(setSearchDetails(searchDetailsObj));
|
store.dispatch(setSearchDetails(searchDetailsObj));
|
||||||
store.dispatch(
|
store.dispatch(
|
||||||
|
|||||||
Reference in New Issue
Block a user