17025 email notiofications fixes
This commit is contained in:
@@ -115,6 +115,27 @@ const TopThree = (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) => {
|
||||
|
||||
@@ -12,6 +12,8 @@ import {
|
||||
getAwaitingSubmissionFromBlobProxy,
|
||||
getRepsFromBlobProxy,
|
||||
getWatchedCasesProxy,
|
||||
getWatchedCases,
|
||||
createWatchedCases,
|
||||
} from "../../actions";
|
||||
import { getDetailsProxy, getFormCollectionByID } from "../../components/utils";
|
||||
import transLookup from "../../data/lookuptranslations.json";
|
||||
@@ -272,12 +274,21 @@ const ViewAllResults = (props) => {
|
||||
/>
|
||||
{viewAllKey == "myRepresentations" && (
|
||||
<>
|
||||
<br />
|
||||
<span>
|
||||
<span className="govuk-body govuk-!-font-size-14">
|
||||
{resultsArr[key].representationType}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
{viewAllKey == "mySubmittedReps" && (
|
||||
<>
|
||||
<span className="govuk-body govuk-!-font-size-14">
|
||||
{item.pinswg_representationtype}{" "}
|
||||
{formatDates(
|
||||
item.pinswg_representationsubmitted
|
||||
)}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</dd>
|
||||
@@ -415,10 +426,15 @@ const ViewAllResults = (props) => {
|
||||
{/* Helper function to extract address lines based on current view and data */}
|
||||
{[
|
||||
"pinswg_siteaddressline1",
|
||||
"pinswg_addressline1",
|
||||
"pinswg_siteaddressline2",
|
||||
"pinswg_addressline2",
|
||||
"pinswg_siteaddresstown",
|
||||
"pinswg_addresstown",
|
||||
"pinswg_siteaddresscounty",
|
||||
"pinswg_siteaddresspostcode",
|
||||
"pinswg_postcode",
|
||||
"pinswg_projectlocation",
|
||||
].map((field, idx) => {
|
||||
const isAwaitingSubmission =
|
||||
viewAllKey === "awaitingSubmissionDetails";
|
||||
@@ -426,7 +442,7 @@ const ViewAllResults = (props) => {
|
||||
viewAllKey === "myRepresentations";
|
||||
const searchValue = _.get(
|
||||
searchDetailsObj,
|
||||
`${key}.${field}`
|
||||
`${key}.${field} `
|
||||
);
|
||||
const detailsValue = _.get(detailsObj, field);
|
||||
|
||||
@@ -738,12 +754,15 @@ const ViewAllResults = (props) => {
|
||||
)}
|
||||
|
||||
{viewAllKey == "watchedCases" && (
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-16 cardModuleItem ">
|
||||
<dd
|
||||
className="govuk-summary-list__value govuk-!-font-size-16 cardModuleItem govuk-!-font-size-14 govuk-summary-list__action"
|
||||
style={{ display: "flex", flexDirection: "column" }}
|
||||
>
|
||||
<button
|
||||
title={t(
|
||||
"case:do-you-want-to-delete-case-label"
|
||||
)}
|
||||
className=" cardModuleRemoveCase govuk-link govuk-link--no-underline govuk-link--inverse "
|
||||
className=" govuk-summary-list__actionLink watched_link"
|
||||
onClick={() => {
|
||||
confirm(
|
||||
t(
|
||||
@@ -761,13 +780,61 @@ const ViewAllResults = (props) => {
|
||||
>
|
||||
—
|
||||
</button>
|
||||
{item.pinswg_emailnotifications == true ? (
|
||||
<button
|
||||
className="govuk-summary-list__actionLink mailLink watched_link"
|
||||
title="Unsubscribe to email updates"
|
||||
onClick={() => {
|
||||
confirm(
|
||||
" Do you want to unsubscribe to email updates for " +
|
||||
item.pinswg_title +
|
||||
"?"
|
||||
) &&
|
||||
selectEmailNotifications(
|
||||
props.accountDetails
|
||||
.accountDetails
|
||||
.emailaddress1,
|
||||
props.accountDetails
|
||||
.loggedinUserId,
|
||||
item._pinswg_watchedcase_value,
|
||||
item.pinswg_appealcasetype,
|
||||
null
|
||||
);
|
||||
}}
|
||||
>
|
||||
<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.pinswg_title +
|
||||
"?"
|
||||
) &&
|
||||
selectEmailNotifications(
|
||||
props.accountDetails
|
||||
.accountDetails
|
||||
.emailaddress1,
|
||||
props.accountDetails
|
||||
.loggedinUserId,
|
||||
item._pinswg_watchedcase_value,
|
||||
item.pinswg_appealcasetype,
|
||||
true
|
||||
);
|
||||
}}
|
||||
>
|
||||
<span className="mailicon icon"></span>
|
||||
</button>
|
||||
)}
|
||||
</dd>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
};
|
||||
buildResultsRowArr();
|
||||
|
||||
const sortDataBy = (whichField) => {
|
||||
setOrderbyState(whichField);
|
||||
@@ -861,6 +928,7 @@ const ViewAllResults = (props) => {
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const deleteItem = (caseID, topThreeType) => {
|
||||
let cookies = parseCookies();
|
||||
//console.log("sssss", caseID, topThreeType);
|
||||
@@ -884,6 +952,78 @@ const ViewAllResults = (props) => {
|
||||
});
|
||||
};
|
||||
|
||||
const isEmailSignUp = (whichIncident) => {
|
||||
let isEmail = jsonpath({
|
||||
path:
|
||||
"$[?(@ && @._pinswg_watchedcase_value=='" +
|
||||
whichIncident +
|
||||
"' && @.pinswg_emailnotifications==true)]",
|
||||
|
||||
json: resultsArr,
|
||||
eval: true,
|
||||
});
|
||||
return isEmail;
|
||||
};
|
||||
|
||||
const selectEmailNotifications = (
|
||||
emailaddress,
|
||||
loggedInUser,
|
||||
incidentID,
|
||||
appealType,
|
||||
updateEmailNotifications
|
||||
) => {
|
||||
let updateBody = {
|
||||
"pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")",
|
||||
"pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")",
|
||||
"pinswg_appealcasetype": appealType,
|
||||
"pinswg_emailnotifications": updateEmailNotifications,
|
||||
};
|
||||
|
||||
console.log("Email signed up");
|
||||
createWatchedCases(updateBody)
|
||||
.then((data) => data)
|
||||
.then(() => {
|
||||
getWatchedCases(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) => {
|
||||
setWatchedCasesDetails(data);
|
||||
})
|
||||
.then(() => {
|
||||
setCurrentView({
|
||||
"viewName": "Watched Cases",
|
||||
"viewKey": "watchedCases",
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
buildResultsRowArr();
|
||||
return (
|
||||
<>
|
||||
<div className="govuk-grid-row">
|
||||
|
||||
Reference in New Issue
Block a user