direct link to case page by ticketnumber
This commit is contained in:
@@ -420,6 +420,19 @@ const Breadcrumbs = (props) => {
|
||||
""
|
||||
)}
|
||||
|
||||
{router.pathname == "/case/[ticketnumber]" ? (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:breadcrumb-case-reference")}:{" "}
|
||||
{
|
||||
props.props.searchResultsObj
|
||||
.searchResultsObj.value[0].title
|
||||
}
|
||||
</li>
|
||||
</>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
{router.pathname == "/myportal/dnsapplications" ? (
|
||||
<>
|
||||
{" "}
|
||||
|
||||
@@ -32,6 +32,7 @@ const Case = (props) => {
|
||||
currentType={props.currentType}
|
||||
appealTypeID={props.appealTypeID}
|
||||
searchResultsObj={props.searchResultsObj}
|
||||
directSearchResultsObj={props.directSearchResultsObj}
|
||||
searchDetailsObj={props.searchDetailsObj}
|
||||
searchString={props.searchString}
|
||||
incidentid={props.incidentid}
|
||||
|
||||
+51
-18
@@ -69,6 +69,7 @@ const CaseSummary = (props) => {
|
||||
awaitingSubmission,
|
||||
searchResultsObj,
|
||||
searchDetailsObj,
|
||||
directSearchResultsObj,
|
||||
currentType,
|
||||
setCurrentLinkedCases,
|
||||
linkedCasesReference,
|
||||
@@ -79,9 +80,9 @@ const CaseSummary = (props) => {
|
||||
currentView,
|
||||
} = props;
|
||||
|
||||
const showLoginCheck = currentView.showLogin;
|
||||
const showLoginCheck =
|
||||
currentType == "directResultsObj" ? "true" : currentView.showLogin;
|
||||
const { data: session, status } = useSession();
|
||||
//console.log("session status:", status, session);
|
||||
|
||||
const cookies = parseCookies();
|
||||
|
||||
@@ -182,6 +183,8 @@ const CaseSummary = (props) => {
|
||||
'$..[?(@.pinswg_title=="' + caseReference + '")]',
|
||||
setCaseQueryObj
|
||||
))
|
||||
: currentType == "directResultsObj"
|
||||
? (casesObj = directSearchResultsObj.value)
|
||||
: (casesObj = jsonpath(
|
||||
'$..[?(@.reference=="' + caseReference + '")]',
|
||||
setCaseQueryObj
|
||||
@@ -196,6 +199,8 @@ const CaseSummary = (props) => {
|
||||
'$..[?(@.pinswg_name=="' + caseReference + '")]',
|
||||
searchDetailsObj
|
||||
))
|
||||
: currentType == "directResultsObj"
|
||||
? (detailsObj = searchDetailsObj[0].value)
|
||||
: (detailsObj = jsonpath(
|
||||
'$..[?(@.pinswg_name=="' + caseReference + '")]',
|
||||
setCaseDetailsObj
|
||||
@@ -226,6 +231,10 @@ const CaseSummary = (props) => {
|
||||
{t("case:summary-reference-label")}:{" "}
|
||||
{currentType == "searchResultsObj"
|
||||
? detailsObj.pinswg_name
|
||||
: currentType == "directResultsObj"
|
||||
? casesObj.title
|
||||
: currentType == "watchedCases"
|
||||
? casesObj.pinswg_title
|
||||
: casesObj.reference}
|
||||
</h1>
|
||||
|
||||
@@ -367,12 +376,12 @@ const CaseSummary = (props) => {
|
||||
<dd className="govuk-summary-list__value">
|
||||
{router.locale == "cy"
|
||||
? jsonpath(
|
||||
transLookup,
|
||||
'$..[?(@.value=="' +
|
||||
detailsObj[
|
||||
"pinswg_casestage@OData.Community.Display.V1.FormattedValue"
|
||||
] +
|
||||
'")].value_cy'
|
||||
'")].value_cy',
|
||||
transLookup
|
||||
)
|
||||
: detailsObj[
|
||||
"pinswg_casestage@OData.Community.Display.V1.FormattedValue"
|
||||
@@ -531,14 +540,32 @@ const CaseSummary = (props) => {
|
||||
.currentReference +
|
||||
"\n\nYou will now be prompted to sign in"
|
||||
) &&
|
||||
signIn("email", {
|
||||
callbackUrl:
|
||||
"/myportal/searchresults?q=" +
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.currentReference,
|
||||
});
|
||||
// signIn("email", {
|
||||
// callbackUrl:
|
||||
// "/myportal/case/" +
|
||||
// props
|
||||
// .currentView
|
||||
// .caseReference
|
||||
// .ticketnumber,
|
||||
// });
|
||||
|
||||
setCookie(
|
||||
null,
|
||||
"pedwWatchCase",
|
||||
currentType ==
|
||||
"searchResultsObj"
|
||||
? detailsObj.pinswg_name
|
||||
: currentType ==
|
||||
"directResultsObj"
|
||||
? casesObj.title
|
||||
: casesObj.reference,
|
||||
{
|
||||
path: "/",
|
||||
expires:
|
||||
expDate,
|
||||
}
|
||||
),
|
||||
signIn();
|
||||
}}
|
||||
title={t(
|
||||
"case:watch-this-case-link"
|
||||
@@ -921,13 +948,10 @@ const CaseSummary = (props) => {
|
||||
const linkedCases = linkCaseObj();
|
||||
}, [incidentid, setCurrentLinkedCases]);
|
||||
|
||||
// const [showSpinnerState, setShowSpinnerState] = useState(false);
|
||||
let now = new Date();
|
||||
let expDate = new Date(now);
|
||||
|
||||
// let spinnerState = () => {
|
||||
// showSpinnerState == true
|
||||
// ? setShowSpinnerState(false)
|
||||
// : setShowSpinnerState(true);
|
||||
// };
|
||||
expDate.setDate(now.getDate() + 365);
|
||||
|
||||
function formatDates(dateObj, showTime) {
|
||||
var dateObj = new Date(dateObj);
|
||||
@@ -998,6 +1022,15 @@ const CaseSummary = (props) => {
|
||||
return date > start && date > end ? true : false;
|
||||
}
|
||||
|
||||
if (status == "authenticated" && cookies.pedwWatchCase != null) {
|
||||
selectWatchedCase(
|
||||
props.accountDetails.accountDetails.contactid,
|
||||
incidentid,
|
||||
appealTypeID
|
||||
);
|
||||
destroyCookie({}, "pedwWatchCase", { path: "/" });
|
||||
}
|
||||
|
||||
return <>{showDetailsBlock}</>;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import Head from "next/head";
|
||||
import { useRouter } from "next/router";
|
||||
import { connect } from "react-redux";
|
||||
import {
|
||||
getBasicSearch,
|
||||
getIP,
|
||||
getPortalLogin,
|
||||
getPersonalAccount,
|
||||
} from "../../actions";
|
||||
import CookieBanner from "../../components/cookieBanner";
|
||||
import Footer from "../../components/footer";
|
||||
import Header from "../../components/header";
|
||||
import { getSearchDetails } from "../../components/utils";
|
||||
import { setCurrentReference } from "../../store/currentView/action";
|
||||
import { setSearch } from "../../store/search/action";
|
||||
import {
|
||||
setSearchDetails,
|
||||
setSearchResults,
|
||||
} from "../../store/searchOutput/action";
|
||||
import { wrapper } from "../../store/store";
|
||||
import Case from "../../components/case";
|
||||
import Breadcrumbs from "../../components/breadcrumbs";
|
||||
import { getSession, useSession } from "next-auth/react";
|
||||
import {
|
||||
setAccountDetails,
|
||||
setContainerID,
|
||||
setLoggedInUserId,
|
||||
} from "../../store/accountDetails/action";
|
||||
|
||||
const CaseHome = (props) => {
|
||||
const { footerLinks, pages } = props;
|
||||
let { t, lang } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
const { ticketnumber } = router.query;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Head>
|
||||
<title>
|
||||
Reference:{" "}
|
||||
{props.currentView.caseReference.currentReference}{" "}
|
||||
</title>
|
||||
</Head>
|
||||
<div id="page_wrapper">
|
||||
<CookieBanner />
|
||||
<Header serviceName="Developments of National Significance" />
|
||||
<div className="govuk-width-container">
|
||||
<Breadcrumbs slug={ticketnumber} props={props} />
|
||||
|
||||
<Case
|
||||
props={props}
|
||||
myCases={props.myCases.myCases}
|
||||
myCasesDetails={props.myCases.myCasesDetails}
|
||||
directSearchResultsObj={
|
||||
props.searchResultsObj.searchResultsObj
|
||||
}
|
||||
searchDetailsObj={
|
||||
props.searchResultsObj.searchDetailsObj
|
||||
}
|
||||
documentDetailsObj={props.documentDetailsObj}
|
||||
myRepresentations={
|
||||
props.myRepresentations.myRepresentations
|
||||
}
|
||||
watchedCases={props.watchedCases.watchedCases}
|
||||
watchedCasesDetails={
|
||||
props.watchedCases.watchedCasesDetails
|
||||
}
|
||||
awaitingSubmission={
|
||||
props.awaitingSubmission.awaitingSubmission
|
||||
}
|
||||
caseReference={
|
||||
props.searchResultsObj.searchResultsObj.value[0]
|
||||
.ticketnumber
|
||||
}
|
||||
currentType={props.currentType}
|
||||
appealTypeID={
|
||||
props.searchResultsObj.searchResultsObj.value[0]
|
||||
.pinswg_appealcasetype
|
||||
}
|
||||
incidentid={
|
||||
props.searchResultsObj.searchResultsObj.value[0]
|
||||
.incidentid
|
||||
}
|
||||
representationsObj={
|
||||
props.searchResultsObj.representationsObj
|
||||
}
|
||||
showLoginCheck={true}
|
||||
/>
|
||||
</div>
|
||||
<Footer
|
||||
footerLinks={footerLinks}
|
||||
props={props}
|
||||
ticketnumber={
|
||||
props.searchResultsObj.searchResultsObj.value[0]
|
||||
.ticketnumber
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) => async (ctx) => {
|
||||
const { query, req, res } = ctx;
|
||||
getIP(req);
|
||||
const { cookies } = req;
|
||||
|
||||
console.log(cookies);
|
||||
console.log("the query :", query.ticketnumber);
|
||||
|
||||
let thisSession = await getSession(ctx);
|
||||
let loggedInUser = {};
|
||||
|
||||
if (thisSession) {
|
||||
console.log(" has sesssion.......");
|
||||
[loggedInUser] = await Promise.all([
|
||||
await getPortalLogin(thisSession.user.email),
|
||||
]);
|
||||
|
||||
loggedInUser = loggedInUser.value[0].contactid;
|
||||
|
||||
const accountDetails = await getPersonalAccount(loggedInUser);
|
||||
store.dispatch(setAccountDetails(accountDetails));
|
||||
} else {
|
||||
console.log("not has sesssion.......");
|
||||
}
|
||||
|
||||
let developmentQuery =
|
||||
query.ticketnumber.indexOf("CAS-") == 0
|
||||
? query.ticketnumber
|
||||
: query.ticketnumber.split("-").join(" ");
|
||||
|
||||
const searchResultsObj = await getBasicSearch(developmentQuery);
|
||||
const searchDetailsObj = await getSearchDetails(searchResultsObj);
|
||||
|
||||
console.log(
|
||||
"\n======================================\n",
|
||||
searchResultsObj,
|
||||
"\n======================================\n"
|
||||
);
|
||||
console.log(
|
||||
"\n======================================\n",
|
||||
searchDetailsObj[0],
|
||||
"\n======================================\n"
|
||||
);
|
||||
|
||||
store.dispatch(setSearch(developmentQuery));
|
||||
|
||||
console.log(
|
||||
searchResultsObj["@odata.count"] > 1 ||
|
||||
searchResultsObj["@odata.count"] < 1
|
||||
);
|
||||
|
||||
if (searchResultsObj["@odata.count"] < 1) {
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/404",
|
||||
permanent: false,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
if (searchResultsObj["@odata.count"] > 1) {
|
||||
return {
|
||||
redirect: {
|
||||
//destination: "/dns-not-found",
|
||||
destination: "/404",
|
||||
permanent: false,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
store.dispatch(
|
||||
setCurrentReference({
|
||||
"ticketnumber": searchResultsObj.value[0].ticketnumber,
|
||||
"currentReference": searchResultsObj.value[0].title,
|
||||
"currentType": "searchResultsObj",
|
||||
"incidentid": searchResultsObj.value[0].incidentid,
|
||||
"appealType":
|
||||
searchResultsObj.value[0].pinswg_appealcasetype,
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
// console.log(searchResultsObj);
|
||||
return {
|
||||
props: {
|
||||
searchResultsObj: {
|
||||
searchResultsObj: searchResultsObj,
|
||||
searchDetailsObj: searchDetailsObj,
|
||||
},
|
||||
currentType: "directResultsObj",
|
||||
},
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
accountDetails: state.accountDetails,
|
||||
currentView: state.currentView,
|
||||
search: state.search,
|
||||
//searchResultsObj: state.searchResultsObj,
|
||||
documentDetailsObj: state.searchResultsObj.documentDetailsObj,
|
||||
formData: state.formData,
|
||||
appealType: state.appealType,
|
||||
form: state.form,
|
||||
myCases: state.myCases,
|
||||
watchedCases: state.watchedCases,
|
||||
myRepresentations: state.myRepresentations,
|
||||
awaitingSubmission: state.awaitingSubmission,
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
setCurrentReference: (currentReference) => {
|
||||
dispatch(setCurrentReference(refno));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(CaseHome);
|
||||
Reference in New Issue
Block a user