diff --git a/components/case/summary.js b/components/case/summary.js
index 3a23f05c..35a485b8 100644
--- a/components/case/summary.js
+++ b/components/case/summary.js
@@ -187,6 +187,27 @@ const CaseSummary = (props) => {
.then((data) => data)
.then(() => {
getWatchedCasesProxy(cookies.pinsUser).then((data) => {
+ 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,
+ });
+ };
+
+ data = showWatchedCases(data);
+
+ data.value.sort(function compare(a, b) {
+ var dateA = new Date(a.createdon);
+ var dateB = new Date(b.createdon);
+ return dateB - dateA;
+ });
setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then(
(data) => {
@@ -1266,12 +1287,44 @@ const CaseSummary = (props) => {
{t(
"case:watch-this-case-link"
)}
+ {" "}
+
- {/* */}
>
)}
diff --git a/components/myportal/viewall.js b/components/myportal/viewall.js
index 43a2bbfb..0a39c4bc 100644
--- a/components/myportal/viewall.js
+++ b/components/myportal/viewall.js
@@ -759,9 +759,7 @@ const ViewAllResults = (props) => {
style={{ display: "flex", flexDirection: "column" }}
>
{item.pinswg_emailnotifications == true ? (
+ {
+ confirm(
+ t(
+ "case:summary-subscribe-mail-label"
+ ) +
+ item.pinswg_name +
+ "?"
+ ) &&
+ signIn(undefined, {
+ callbackUrl:
+ "/myportal/addresssearchresults?" +
+ new URLSearchParams(
+ searchString
+ ) +
+ "&toWatch=" +
+ item.incidentid +
+ "_" +
+ item.pinswg_appealcasetype,
+ });
+ }}
+ >
+
+
)}
diff --git a/components/search/dnssearchresults.js b/components/search/dnssearchresults.js
index 01708b5a..45c5b090 100644
--- a/components/search/dnssearchresults.js
+++ b/components/search/dnssearchresults.js
@@ -170,6 +170,36 @@ const DNSSearchResults = (props) => {
});
};
+ 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:
@@ -183,6 +213,19 @@ const DNSSearchResults = (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" &&
@@ -190,6 +233,27 @@ const DNSSearchResults = (props) => {
.then((data) => data)
.then(() => {
getWatchedCasesProxy(cookies.pinsUser).then((data) => {
+ 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,
+ });
+ };
+
+ data = showWatchedCases(data);
+
+ data.value.sort(function compare(a, b) {
+ var dateA = new Date(a.createdon);
+ var dateB = new Date(b.createdon);
+ return dateB - dateA;
+ });
setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then(
(data) => {
@@ -566,7 +630,7 @@ const DNSSearchResults = (props) => {
.length >
0 ==
true ? (
- {
confirm(
@@ -590,9 +654,9 @@ const DNSSearchResults = (props) => {
)}
>
-
+
) : (
- {
confirm(
@@ -613,7 +677,61 @@ const DNSSearchResults = (props) => {
)}
>
-
+
+ )}
+ {isEmailSignUp(item.incidentid)
+ .length >
+ 0 ==
+ true ? (
+ {
+ confirm(
+ t(
+ "case:summary-unsubscribe-mail-label"
+ ) +
+ item.title +
+ "?"
+ ) &&
+ deleteItem(
+ isEmailSignUp(
+ item.incidentid
+ )[0]
+ .pinswg_watchlistid,
+
+ "watchedCases"
+ );
+ }}
+ >
+
+
+ ) : (
+ {
+ confirm(
+ t(
+ "case:summary-subscribe-mail-label"
+ ) +
+ item.title +
+ "?"
+ ) &&
+ selectEmailNotifications(
+ props
+ .accountDetails
+ .emailaddress1,
+ props
+ .accountDetails
+ .loggedinUserId,
+ item.incidentid,
+ item.pinswg_appealcasetype
+ );
+ }}
+ >
+
+
)}
)}
@@ -868,4 +986,13 @@ const mapDispatchToProps = (dispatch) => {
};
};
-export default connect(null, mapDispatchToProps)(DNSSearchResults);
+const mapStateToProps = (state) => {
+ return {
+ // currentView: state.currentView,
+ accountDetails: state.accountDetails,
+ // search: state.search,
+ // searchResultsObj: state.searchResultsObj,
+ };
+};
+
+export default connect(mapStateToProps, mapDispatchToProps)(DNSSearchResults);
diff --git a/components/search/searchresults.js b/components/search/searchresults.js
index 59448d2d..b8803fec 100644
--- a/components/search/searchresults.js
+++ b/components/search/searchresults.js
@@ -180,6 +180,27 @@ const SearchResults = (props) => {
getWatchedCasesProxy(
props.accountDetails.loggedinUserId
).then((data) => {
+ 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,
+ });
+ };
+
+ data = showWatchedCases(data);
+
+ data.value.sort(function compare(a, b) {
+ var dateA = new Date(a.createdon);
+ var dateB = new Date(b.createdon);
+ return dateB - dateA;
+ });
setWatchedCases(data),
getDetailsProxy(data, "myWatchedCases").then(
(data) => {
@@ -690,7 +711,9 @@ const SearchResults = (props) => {
title="Email about changes"
onClick={() => {
confirm(
- " Do you want to be sent email updates for " +
+ t(
+ "case:summary-subscribe-mail-label"
+ ) +
item.title +
"?"
) &&
@@ -754,10 +777,14 @@ const SearchResults = (props) => {
{
confirm(
- " Do you want to be sent email updates for " +
+ t(
+ "case:summary-subscribe-mail-label"
+ ) +
item.title +
"?"
) &&
diff --git a/i18n.js b/i18n.js
index e1561f1f..4515ae36 100644
--- a/i18n.js
+++ b/i18n.js
@@ -22,7 +22,12 @@ module.exports = {
"/myportal/searchresults": ["search", "myportal", "case"],
"/myportal/case": ["case"],
"/myportal/case/[ticketnumber]": ["case"],
- "/myportal/dnsapplications": ["search", "dnsCommon", "dnsApplications"],
+ "/myportal/dnsapplications": [
+ "search",
+ "dnsCommon",
+ "dnsApplications",
+ "case",
+ ],
"/myportal/dnsdetails": [
"case",
"search",
@@ -61,7 +66,7 @@ module.exports = {
"/dns": ["dnsCommon", "dnsHome"],
"/dns/applications": ["dnsCommon", "dnsApplications"],
"/dns/application-view": ["dnsCommon", "dnsApplicationView"],
- "/dnsapplications": ["search", "dnsCommon", "dnsApplications"],
+ "/dnsapplications": ["search", "dnsCommon", "dnsApplications", "case"],
"/dnsdetails": ["case", "search", "dnsCommon", "dnsApplications"],
"/help/cookies": ["common", "cookies"],
"/account/register": ["common", "account"],
diff --git a/locales/cy/common.json b/locales/cy/common.json
index 4071caca..50abbceb 100644
--- a/locales/cy/common.json
+++ b/locales/cy/common.json
@@ -113,5 +113,7 @@
"contact-us-select-ceq": "Ymholiad Digwyddiadau Gwaith Achos",
"contact-us-select-other": "Unrhyw Ymholiadau Eraill",
"contact-us-select-postdec": "Ar ôl Penderfyniad",
- "contact-us-select-comp": "Cwynion/Canmoliaethau"
+ "contact-us-select-comp": "Cwynion/Canmoliaethau",
+ "unsubscribe-title-label": "Dad-danysgrifio i ddiweddariadau e-bost",
+ "subscribe-title-label": "Tanysgrifio i ddiweddariadau e-bost"
}
\ No newline at end of file
diff --git a/locales/en/common.json b/locales/en/common.json
index 379d6f5a..7fe27e9c 100644
--- a/locales/en/common.json
+++ b/locales/en/common.json
@@ -113,5 +113,7 @@
"contact-us-select-ceq": "Casework Events Query",
"contact-us-select-other": "Any Other Enquiries",
"contact-us-select-postdec": "Post Decision",
- "contact-us-select-comp": "Complaints/Complements"
+ "contact-us-select-comp": "Complaints/Complements",
+ "unsubscribe-title-label": "Unsubscribe to email updates",
+ "subscribe-title-label": "Subscribe to email updates"
}
\ No newline at end of file
diff --git a/pages/myportal/dnsapplications.js b/pages/myportal/dnsapplications.js
index 50c0c104..4cf11cbb 100644
--- a/pages/myportal/dnsapplications.js
+++ b/pages/myportal/dnsapplications.js
@@ -121,6 +121,7 @@ const Home = (props) => {
+