set case to watch on auth
This commit is contained in:
@@ -522,13 +522,7 @@ const CaseSummary = (props) => {
|
||||
className="govuk-link"
|
||||
onClick={() => {
|
||||
// signIn("email");
|
||||
signIn("email", {
|
||||
callbackUrl:
|
||||
"/myportal/searchresults?q=" +
|
||||
props.currentView
|
||||
.caseReference
|
||||
.currentReference,
|
||||
});
|
||||
signIn();
|
||||
// selectWatchedCase(
|
||||
// cookies.pinsUser,
|
||||
// item.incidentid,
|
||||
@@ -541,7 +535,7 @@ const CaseSummary = (props) => {
|
||||
}}
|
||||
title={t("case:watch-this-case-link")}
|
||||
>
|
||||
{t("case:watch-this-case-link")}
|
||||
{t("case:watch-this-case-link")} dd
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
+11
-17
@@ -56,6 +56,16 @@ const Header = (props) => {
|
||||
domainSwitch = process.env.I18N_DOMAIN;
|
||||
}
|
||||
|
||||
const handleLogout = () => {
|
||||
console.info("////////////\n" + "logout" + "\n////////////");
|
||||
window.localStorage.clear(),
|
||||
destroyCookie(null, "next-auth.csrf-token"),
|
||||
destroyCookie(null, "next-auth.callback-url"),
|
||||
destroyCookie(null, "pedw_locale"),
|
||||
destroyCookie(null, "pinsUser"),
|
||||
signOut({ callbackUrl: "/logout" });
|
||||
};
|
||||
|
||||
return (
|
||||
<header
|
||||
className="govuk-header "
|
||||
@@ -219,23 +229,7 @@ const Header = (props) => {
|
||||
>
|
||||
<a
|
||||
onClick={() => {
|
||||
window.localStorage.clear(),
|
||||
destroyCookie(
|
||||
null,
|
||||
"next-auth.csrf-token"
|
||||
),
|
||||
destroyCookie(
|
||||
null,
|
||||
"next-auth.callback-url"
|
||||
),
|
||||
destroyCookie(null, "pedw_locale"),
|
||||
destroyCookie(null, "pinsUser"),
|
||||
signOut({
|
||||
callbackUrl:
|
||||
locale == "cy"
|
||||
? "/allgofnodi"
|
||||
: "/logout",
|
||||
});
|
||||
handleLogout();
|
||||
}}
|
||||
className="govuk-header__link govuk-!-margin-right-3"
|
||||
>
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
setSearchResults,
|
||||
setSearchDetails,
|
||||
} from "../../store/searchOutput/action";
|
||||
import { setLoggedInUserId } from "../../store/accountDetails/action";
|
||||
import {
|
||||
setWatchedCases,
|
||||
setWatchedCasesDetails,
|
||||
@@ -75,6 +76,7 @@ const SearchResults = (props) => {
|
||||
const [selectedOption, setSelectedOption] = useState(10);
|
||||
const [orderByState, setOrderbyState] = useState("createdon");
|
||||
const [fieldSortState, setfieldSortState] = useState("asc");
|
||||
const [loginToWatch, setLoginToWatch] = useState("true");
|
||||
|
||||
let spinnerState = () => {
|
||||
showSpinnerState == true
|
||||
@@ -94,12 +96,14 @@ const SearchResults = (props) => {
|
||||
createWatchedCases(updateBody)
|
||||
.then((data) => data)
|
||||
.then(() => {
|
||||
getWatchedCasesProxy(cookies.pinsUser).then((data) => {
|
||||
setWatchedCases(data),
|
||||
getDetails(data, "myWatchedCases").then((data) => {
|
||||
setWatchedCasesDetails(data);
|
||||
});
|
||||
});
|
||||
getWatchedCasesProxy(props.accountDetails.loggedinUserId).then(
|
||||
(data) => {
|
||||
setWatchedCases(data),
|
||||
getDetails(data, "myWatchedCases").then((data) => {
|
||||
setWatchedCasesDetails(data);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -118,7 +122,9 @@ const SearchResults = (props) => {
|
||||
deleteWatchedCases(caseID)
|
||||
.then((data) => data)
|
||||
.then(() => {
|
||||
getWatchedCasesProxy(cookies.pinsUser).then((data) => {
|
||||
getWatchedCasesProxy(
|
||||
props.accountDetails.loggedinUserId
|
||||
).then((data) => {
|
||||
setWatchedCases(data),
|
||||
getDetails(data, "myWatchedCases").then((data) => {
|
||||
setWatchedCasesDetails(data);
|
||||
@@ -128,7 +134,7 @@ const SearchResults = (props) => {
|
||||
};
|
||||
|
||||
const getDetails = (resultsObj, detailsType) => {
|
||||
//console.log(resultsObj);
|
||||
console.log(resultsObj);
|
||||
let detailsArr = [];
|
||||
resultsObj = resultsObj.value;
|
||||
const detailsObj = resultsObj.map((searchDetail, index) => {
|
||||
@@ -520,7 +526,8 @@ const SearchResults = (props) => {
|
||||
className="govuk-summary-list__actionLink watchLink"
|
||||
onClick={() => {
|
||||
selectWatchedCase(
|
||||
cookies.pinsUser,
|
||||
props.accountDetails
|
||||
.loggedinUserId,
|
||||
item.incidentid,
|
||||
item.pinswg_appealcasetype
|
||||
);
|
||||
@@ -545,13 +552,17 @@ const SearchResults = (props) => {
|
||||
className="govuk-summary-list__actionLink watchLink"
|
||||
onClick={() => {
|
||||
// signIn("email");
|
||||
signIn("email", {
|
||||
signIn(undefined, {
|
||||
callbackUrl:
|
||||
"/myportal/case?q=" +
|
||||
searchString,
|
||||
"/myportal/searchresults?q=" +
|
||||
searchString +
|
||||
"&toWatch=" +
|
||||
item.incidentid +
|
||||
"_" +
|
||||
item.pinswg_appealcasetype,
|
||||
});
|
||||
// selectWatchedCase(
|
||||
// cookies.pinsUser,
|
||||
// props.accountDetails.loggedinUserId,
|
||||
// item.incidentid,
|
||||
// item.pinswg_appealcasetype
|
||||
// );
|
||||
@@ -684,6 +695,30 @@ const SearchResults = (props) => {
|
||||
} else {
|
||||
setSearchLoaded(true);
|
||||
}
|
||||
if (loginToWatch && router.query.hasOwnProperty("toWatch")) {
|
||||
console.log("am in here");
|
||||
let now = new Date();
|
||||
let expDate = new Date(now);
|
||||
|
||||
expDate.setDate(now.getDate() + 1);
|
||||
|
||||
setLoggedInUserId(props.accountDetails.loggedinUserId);
|
||||
setCookie(null, "pinsUser", props.accountDetails.loggedinUserId, {
|
||||
path: "/",
|
||||
expires: expDate,
|
||||
});
|
||||
selectWatchedCase(
|
||||
props.accountDetails.loggedinUserId,
|
||||
router.query.toWatch.split("_")[0],
|
||||
router.query.toWatch.split("_")[1]
|
||||
);
|
||||
getSearchPageResults(1, orderByState, fieldSortState);
|
||||
setLoginToWatch(false);
|
||||
} else {
|
||||
console.log("or am in here");
|
||||
|
||||
setLoginToWatch(false);
|
||||
}
|
||||
}, [
|
||||
selectedOption,
|
||||
fieldSortState,
|
||||
@@ -803,4 +838,12 @@ const mapDispatchToProps = (dispatch) => {
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(null, mapDispatchToProps)(SearchResults);
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
// currentView: state.currentView,
|
||||
accountDetails: state.accountDetails,
|
||||
// search: state.search,
|
||||
// searchResultsObj: state.searchResultsObj,
|
||||
};
|
||||
};
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(SearchResults);
|
||||
|
||||
@@ -37,6 +37,8 @@ export default async function ApiProxy(req, res) {
|
||||
var data = JSON.stringify(req.body);
|
||||
var queryUrl = "pinswg_watchlists";
|
||||
|
||||
console.log(data);
|
||||
|
||||
var config = {
|
||||
method: "post",
|
||||
url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
@@ -51,11 +53,16 @@ export default async function ApiProxy(req, res) {
|
||||
data: data,
|
||||
};
|
||||
|
||||
console.log(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl));
|
||||
console.log(data);
|
||||
|
||||
return axios(config)
|
||||
.then(({ data }) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl));
|
||||
console.log(data);
|
||||
console.log(consoleLogger(err));
|
||||
res.status(400).json(err);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user