diff --git a/components/case/summary.js b/components/case/summary.js
index d5f07bcb..6b163182 100644
--- a/components/case/summary.js
+++ b/components/case/summary.js
@@ -7,14 +7,26 @@ import jsonpath from "jsonpath";
import _ from "lodash";
import transLookup from "../../data/lookuptranslations.json";
-import { getLinkedCases } from "../../actions";
+import {
+ getLinkedCases,
+ createWatchedCases,
+ getWatchedCasesProxy,
+ getPortalModuleDetailsProxy,
+ deleteWatchedCases,
+} from "../../actions";
import {
setCurrentLinkedCases,
setCurrentReference,
} from "../../store/currentView/action";
+import {
+ setWatchedCases,
+ setWatchedCasesDetails,
+} from "../../store/watchedCases/action";
+
import { getFormCollectionByID } from "../utils";
-import { getSession, useSession } from "next-auth/react";
+import { getSession, useSession, signIn } from "next-auth/react";
+import { parseCookies, setCookie, destroyCookie } from "nookies";
import Pinswg_advertsid from "./summaryTypes/pinswg_advertsid";
import Pinswg_callinss77id from "./summaryTypes/pinswg_callinss77id";
@@ -61,12 +73,92 @@ const CaseSummary = (props) => {
setCurrentLinkedCases,
linkedCasesReference,
setCurrentReference,
+ setWatchedCases,
+ setWatchedCasesDetails,
showMap,
+ showLoginCheck,
} = props;
const { data: session, status } = useSession();
//console.log("session status:", status, session);
+ const cookies = parseCookies();
+
+ const selectWatchedCase = (loggedInUser, incidentID, appealType) => {
+ let updateBody = {
+ "pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")",
+ "pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")",
+ "pinswg_appealcasetype": +appealType,
+ };
+
+ createWatchedCases(updateBody)
+ .then((data) => data)
+ .then(() => {
+ getWatchedCasesProxy(loggedInUser).then((data) => {
+ setWatchedCases(data),
+ getDetails(data, "myWatchedCases").then((data) => {
+ setWatchedCasesDetails(data);
+ });
+ });
+ });
+ };
+
+ const getDetails = (resultsObj, detailsType) => {
+ console.log(resultsObj);
+ let detailsArr = [];
+ resultsObj = resultsObj.value;
+ const detailsObj = resultsObj.map((searchDetail, index) => {
+ if (searchDetail.pinswg_appealcasetype == null) {
+ console.log(
+ detailsType != "myWatchedCases"
+ ? searchDetail.ticketnumber
+ : searchDetail[
+ "_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
+ ]
+ );
+ } else {
+ detailsArr.push(
+ getPortalModuleDetailsProxy(
+ getFormCollectionByID(
+ searchDetail.pinswg_appealcasetype
+ ).LogicalCollectionName,
+ detailsType != "myWatchedCases"
+ ? searchDetail.ticketnumber
+ : searchDetail[
+ "_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
+ ]
+ )
+ );
+ }
+ });
+ //console.log(detailsArr);
+ return Promise.all(detailsArr);
+ };
+
+ const isWatchedCase = (whichIncident) => {
+ let isWatched = jsonpath.query(
+ watchedCases,
+ "$..value[?(@._pinswg_watchedcase_value=='" + whichIncident + "')]"
+ );
+
+ return isWatched;
+ };
+
+ const deleteItem = (caseID, topThreeType) => {
+ let cookies = parseCookies();
+ topThreeType == "watchedCases" &&
+ deleteWatchedCases(caseID)
+ .then((data) => data)
+ .then(() => {
+ getWatchedCasesProxy(cookies.pinsUser).then((data) => {
+ setWatchedCases(data),
+ getDetails(data, "myWatchedCases").then((data) => {
+ setWatchedCasesDetails(data);
+ });
+ });
+ });
+ };
+
const noRepresentationLink = ["/dnsdetails", "/dns/[developmentName]"];
let setCaseQueryObj = props[currentType];
@@ -291,81 +383,153 @@ const CaseSummary = (props) => {
- {(props.currentView.showLogin == true ||
- props.currentView.showLogin == "true") && (
-
- )}
- {props.currentView.showReps == true ||
- (props.currentView.showReps == "true" &&
- _.has(detailsObj, "pinswg_startdate") &&
+
+ {_.has(detailsObj, "pinswg_startdate") &&
hasEndDate &&
- showRepsEnded(
+ showReps(
detailsObj.pinswg_startdate,
detailsObj.pinswg_representation_period_end_date
) && (
-
- Representation Period ended on{" "}
- {formatDates(
- detailsObj.pinswg_representation_period_end_date
- )}
-
- ))}
+ <>
+
+
+ {t(
+ "case:summary-make-representation-label"
+ )}
+
+
+
{
+ //spinnerState();
+ router.back();
+ }}
+ className="govuk-button govuk-button--secondary"
+ >
+ {t(
+ "case:summary-back-button-label"
+ )}
+
+ >
+ )}
+
+ {session &&
+ (isWatchedCase(
+ props.currentView.caseReference
+ .incidentid
+ ).length >
+ 0 ==
+ true ? (
+ {
+ deleteItem(
+ isWatchedCase(
+ props.currentView
+ .caseReference
+ .incidentid
+ )[0].pinswg_watchlistid,
+
+ "watchedCases"
+ );
+ alert(
+ "You have stopped watching case " +
+ props.currentView
+ .caseReference
+ .currentReference
+ );
+ }}
+ title="Stop watching this case"
+ >
+ Stop watching this case{" "}
+
+ ) : (
+ {
+ selectWatchedCase(
+ props.accountDetails
+ .loggedinUserId,
+ props.currentView
+ .caseReference
+ .incidentid,
+ props.currentView
+ .caseReference
+ .appealType
+ );
+ alert(
+ "You are watching case " +
+ props.currentView
+ .caseReference
+ .currentReference
+ );
+ }}
+ >
+ Watch this case
+
+ ))}
+
+ {!session && (
+ {
+ // signIn("email");
+ signIn("email", {
+ callbackUrl:
+ "/myportal/searchresults?q=" +
+ props.currentView
+ .caseReference
+ .currentReference,
+ });
+ // selectWatchedCase(
+ // cookies.pinsUser,
+ // item.incidentid,
+ // item.pinswg_appealcasetype
+ // );
+ // alert(
+ // "Trying to watch case " +
+ // item.title
+ // );
+ }}
+ title="Watch this case"
+ >
+ Watch this case
+
+ )}
+
+
+
+
+
+
+
+ {_.has(detailsObj, "pinswg_startdate") &&
+ hasEndDate &&
+ showRepsEnded(
+ detailsObj.pinswg_startdate,
+ detailsObj.pinswg_representation_period_end_date
+ ) && (
+
+ Representation Period ended on{" "}
+ {formatDates(
+ detailsObj.pinswg_representation_period_end_date
+ )}
+
+ )}
{/* 1{" "}
@@ -849,6 +1013,12 @@ const mapDispatchToProps = (dispatch) => {
setCurrentReference: (currentReference) => {
dispatch(setCurrentReference(currentReference));
},
+ setWatchedCases: (watchedCases) => {
+ dispatch(setWatchedCases(watchedCases));
+ },
+ setWatchedCasesDetails: (watchedCasesDetails) => {
+ dispatch(setWatchedCasesDetails(watchedCasesDetails));
+ },
};
};
diff --git a/components/search/searchresults.js b/components/search/searchresults.js
index f55cb111..67d05081 100644
--- a/components/search/searchresults.js
+++ b/components/search/searchresults.js
@@ -533,7 +533,7 @@ const SearchResults = (props) => {
)}
)}
- {/* {showLoginCheck == "true" && !session && (
+ {showLoginCheck == "true" && !session && (
{
// signIn("email");
signIn("email", {
callbackUrl:
- "/myportal/searchresults?q=" +
+ "/myportal/case?q=" +
searchString,
});
// selectWatchedCase(
@@ -559,7 +559,7 @@ const SearchResults = (props) => {
- )} */}
+ )}
);
})
diff --git a/pages/api/endpoint/createwatchedcases_api.js b/pages/api/endpoint/createwatchedcases_api.js
index 0525e796..e49a39f2 100644
--- a/pages/api/endpoint/createwatchedcases_api.js
+++ b/pages/api/endpoint/createwatchedcases_api.js
@@ -9,6 +9,12 @@
* description: Success
*/
+import axios from "axios";
+import CryptoJS from "crypto-js";
+import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions";
+
+const WORDKEY = process.env.HASHKEY;
+
const WEBAPI_URL =
process.env.RELAY_ROOT ||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
diff --git a/pages/api/endpoint/getwatchedcasesproxy_api.js b/pages/api/endpoint/getwatchedcasesproxy_api.js
index 9d63adb0..347aeda7 100644
--- a/pages/api/endpoint/getwatchedcasesproxy_api.js
+++ b/pages/api/endpoint/getwatchedcasesproxy_api.js
@@ -18,7 +18,7 @@
import axios from "axios";
import CryptoJS from "crypto-js";
-import { azureHeaders, getToken } from "../../../actions";
+import { azureHeaders, getToken, consoleLogger } from "../../../actions";
const WORDKEY = process.env.HASHKEY;
diff --git a/pages/myportal/case.js b/pages/myportal/case.js
index 46309a25..d6c8da93 100644
--- a/pages/myportal/case.js
+++ b/pages/myportal/case.js
@@ -91,6 +91,7 @@ const mapStateToProps = (state) => {
watchedCases: state.watchedCases,
myRepresentations: state.myRepresentations,
awaitingSubmission: state.awaitingSubmission,
+ accountDetails: state.accountDetails,
};
};
diff --git a/pages/myportal/searchresults.js b/pages/myportal/searchresults.js
index 1e51cc69..243eb28a 100644
--- a/pages/myportal/searchresults.js
+++ b/pages/myportal/searchresults.js
@@ -111,7 +111,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
const watchedCases = await getWatchedCases(loggedInUser);
- //console.log("sssss", loggedInUser);
+ console.log("sssss", loggedInUser);
const [accountDetails, searchDetailsObj, watchedCasesDetails] =
await Promise.all([
diff --git a/store/store.js b/store/store.js
index 44c85425..a2d41220 100644
--- a/store/store.js
+++ b/store/store.js
@@ -130,7 +130,7 @@ const makeStore = ({ isServer }) => {
//"searchResultsObj",
"appealType",
"LPAData",
- "accountDetails",
+ //"accountDetails",
"awaitingSubmission",
"myCases",
"myRepresentations",