diff --git a/components/case/summary.js b/components/case/summary.js index a85aae3c..3a23f05c 100644 --- a/components/case/summary.js +++ b/components/case/summary.js @@ -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 ? ( + <> + + + ) : ( + <> + + + ))} + {session && + (isEmailSignUp( + props.currentView + .caseReference + .incidentid + ).length > + 0 == true ? ( ) : ( @@ -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" )} - - {/* */} ))} - {!session && ( <> - - - {/*