wip for delete reps in view all
This commit is contained in:
@@ -921,6 +921,32 @@ export const getRepsFromBlob = (containerName) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getRepsFromBlobProxy = (containerName) => {
|
||||
console.log(
|
||||
"///////////////////////getRepsFromBlobProxy: " + containerName,
|
||||
"/api/file/getawaitingsubmissionfromblobproxy?container=" +
|
||||
containerName,
|
||||
"\n///////////////////////\n"
|
||||
);
|
||||
|
||||
return axios
|
||||
.get(
|
||||
// BASE_URL +
|
||||
"/api/file/getrepsblobproxy?container=" + containerName
|
||||
// +
|
||||
// hashAPIPath(
|
||||
// "/api/file/getawaitingsubmissionfromblob?container=" +
|
||||
// containerName
|
||||
// )
|
||||
)
|
||||
.then((res) => {
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getAwaitingSubmissionFromBlobProxy = (containerName) => {
|
||||
console.log(
|
||||
"///////////////////////getAwaitingSubmissionFromBlobProxy: " +
|
||||
@@ -1324,6 +1350,34 @@ export const deleteAwaitingSubmissionsFromBlob = (
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteMyRepresentationsFromBlob = (
|
||||
containerID,
|
||||
casefolderID,
|
||||
repfile
|
||||
) => {
|
||||
var queryUrl =
|
||||
"/api/file/deleteblobrep?container=" +
|
||||
containerID +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
"&repfile=" +
|
||||
repfile;
|
||||
|
||||
var config = {
|
||||
method: "get",
|
||||
url: queryUrl,
|
||||
};
|
||||
//console.log(config);
|
||||
return axios(config)
|
||||
.then((res) => {
|
||||
//console.log("deleted ", res.data);
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("this serror", error);
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteWatchedCases = (watchedCaseID) => {
|
||||
var queryUrl =
|
||||
"/api/endpoint/deletewatchedcases_api?watchedCaseID=" + watchedCaseID;
|
||||
|
||||
+77
-10
@@ -4,11 +4,17 @@ import _ from "lodash";
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
|
||||
|
||||
import { getSession, useSession } from "next-auth/react";
|
||||
import {
|
||||
setCurrentLinkedCases,
|
||||
setCurrentReference,
|
||||
setCurrentView,
|
||||
} from "../store/currentView/action";
|
||||
|
||||
const Breadcrumbs = (props) => {
|
||||
const { courseContent, slug, currentView } = props;
|
||||
const { courseContent, slug, currentView, setCurrentView } = props;
|
||||
const router = useRouter();
|
||||
const { appealType, section } = router.query;
|
||||
|
||||
@@ -456,16 +462,18 @@ const Breadcrumbs = (props) => {
|
||||
</Link>
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{currentView.viewKey ==
|
||||
{currentView.currentView.viewKey ==
|
||||
"awaitingSubmissionDetails" &&
|
||||
t(
|
||||
"myportal:awatitingsubmission-card-title"
|
||||
)}
|
||||
{currentView.viewKey == "watchedCases" &&
|
||||
{currentView.currentView.viewKey ==
|
||||
"watchedCases" &&
|
||||
t("myportal:watchedcases-card-title")}
|
||||
{currentView.viewKey == "myCases" &&
|
||||
{currentView.currentView.viewKey ==
|
||||
"myCases" &&
|
||||
t("myportal:mycases-card-title")}
|
||||
{currentView.viewKey ==
|
||||
{currentView.currentView.viewKey ==
|
||||
"myRepresentations" &&
|
||||
t(
|
||||
"myportal:myrepresentations-card-title"
|
||||
@@ -491,7 +499,7 @@ const Breadcrumbs = (props) => {
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
</Link>
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{/* <li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
@@ -501,10 +509,18 @@ const Breadcrumbs = (props) => {
|
||||
: "/myportal/viewall"
|
||||
}
|
||||
className="govuk-breadcrumbs__link"
|
||||
onClick={() => {
|
||||
setCurrentView({
|
||||
"viewName":
|
||||
"Awaiting Submission",
|
||||
"viewKey":
|
||||
"awaitingSubmissionDetails",
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t("common:breadcrumb-your-cases")}
|
||||
</Link>
|
||||
</li>
|
||||
</li> */}
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:breadcrumb-case-reference")}:{" "}
|
||||
{
|
||||
@@ -648,6 +664,35 @@ const Breadcrumbs = (props) => {
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
|
||||
{router.pathname == "/myportal/case/[ticketnumber]" ? (
|
||||
<>
|
||||
{" "}
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
</Link>
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:breadcrumb-case-reference")}:{" "}
|
||||
{
|
||||
props.props.currentView.caseReference
|
||||
.currentReference
|
||||
}
|
||||
</li>
|
||||
</>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
{router.pathname == "/myportal/dnsapplications" ? (
|
||||
<>
|
||||
{" "}
|
||||
@@ -764,8 +809,15 @@ const Breadcrumbs = (props) => {
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? router.locale + "/case"
|
||||
: "/case"
|
||||
? router.locale +
|
||||
"/myportal/case" +
|
||||
props.props.currentView
|
||||
.caseReference
|
||||
.currentReference
|
||||
: "/myportal/case/" +
|
||||
props.props.currentView
|
||||
.caseReference
|
||||
.currentReference
|
||||
}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
@@ -1080,4 +1132,19 @@ const Breadcrumbs = (props) => {
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default Breadcrumbs;
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
...state,
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
setCurrentView: (currentView) => {
|
||||
dispatch(setCurrentView(currentView));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Breadcrumbs);
|
||||
|
||||
@@ -16,6 +16,10 @@ import {
|
||||
import { setAwaitingSubmissionFromBlob } from "../../store/awaitingSubmission/action";
|
||||
import { parseCookies, setCookie, destroyCookie } from "nookies";
|
||||
import { getFormCollectionByID } from "../../components/utils";
|
||||
import {
|
||||
setAwaitingSubmission,
|
||||
setAwaitingSubmissionDetails,
|
||||
} from "../../store/awaitingSubmission/action";
|
||||
|
||||
const AwaitingSubmissionFromBlob = (props) => {
|
||||
let { t } = useTranslation();
|
||||
@@ -55,6 +59,7 @@ const AwaitingSubmissionFromBlob = (props) => {
|
||||
.then(() => {
|
||||
getAwaitingSubmissionFromBlobProxy(containerID).then((data) => {
|
||||
props.setAwaitingSubmissionFromBlob(data);
|
||||
props.setAwaitingSubmissionDetails(data);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -350,6 +355,9 @@ const mapDispatchToProps = (dispatch) => {
|
||||
setAwaitingSubmissionFromBlob: (awaitingSubmission) => {
|
||||
dispatch(setAwaitingSubmissionFromBlob(awaitingSubmission));
|
||||
},
|
||||
setAwaitingSubmissionDetails: (awaitingSubmissionDetails) => {
|
||||
dispatch(setAwaitingSubmissionDetails(awaitingSubmissionDetails));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -17,8 +17,10 @@ import {
|
||||
deleteWatchedCases,
|
||||
deleteAwaitingSubmissions,
|
||||
deleteAwaitingSubmissionsFromBlob,
|
||||
deleteMyRepresentationsFromBlob,
|
||||
getAwaitingSubmissionFromBlobProxy,
|
||||
getAwaitingSubmissionProxy,
|
||||
getRepsFromBlobProxy,
|
||||
} from "../../actions";
|
||||
import { setAwaitingSubmissionFromBlob } from "../../store/awaitingSubmission/action";
|
||||
|
||||
@@ -36,6 +38,12 @@ import {
|
||||
setCurrentReference,
|
||||
setCurrentView,
|
||||
} from "../../store/currentView/action";
|
||||
import {
|
||||
setMyRepresentations,
|
||||
setMyRepresentationsDetails,
|
||||
setMySubmittedReps,
|
||||
setMySubmittedRepsDetails,
|
||||
} from "../../store/myRepresentations/action";
|
||||
|
||||
const ViewAllResults = (props) => {
|
||||
const {
|
||||
@@ -48,6 +56,10 @@ const ViewAllResults = (props) => {
|
||||
accountDetails,
|
||||
setAwaitingSubmissionFromBlob,
|
||||
setAwaitingSubmissionDetails,
|
||||
setWatchedCasesDetails,
|
||||
setWatchedCases,
|
||||
setMyRepresentations,
|
||||
setMyRepresentationsDetails,
|
||||
} = props;
|
||||
|
||||
let { t } = useTranslation();
|
||||
@@ -101,10 +113,19 @@ const ViewAllResults = (props) => {
|
||||
const buildResultsRowArr = () => {
|
||||
resultsArr.map((item, key) => {
|
||||
let detailsObj = jsonpath(
|
||||
'$..value[?(@.pinswg_name=="' + currentView.viewKey ==
|
||||
"awaitingSubmissionDetails"
|
||||
"$" +
|
||||
(currentView.viewKey == "myRepresentations"
|
||||
? ""
|
||||
: "..value") +
|
||||
'[?(@.pinswg_name=="' +
|
||||
(currentView.viewKey == "awaitingSubmissionDetails"
|
||||
? item.title
|
||||
: item.pinswg_title + '")]',
|
||||
: currentView.viewKey == "watchedCases"
|
||||
? item.ticketnumber
|
||||
: currentView.viewKey == "myRepresentations"
|
||||
? item.pinswg_name
|
||||
: item.pinswg_title) +
|
||||
'")]',
|
||||
searchDetailsObj
|
||||
);
|
||||
detailsObj = detailsObj[0];
|
||||
@@ -163,8 +184,10 @@ const ViewAllResults = (props) => {
|
||||
? "/fymhorth/achos"
|
||||
: "/achos"
|
||||
: myportal == true
|
||||
? "/myportal/case"
|
||||
: "/case"
|
||||
? "/myportal/case/" +
|
||||
resultsArr[key].ticketnumber
|
||||
: "/case/" +
|
||||
resultsArr[key].ticketnumber
|
||||
}
|
||||
onClick={() => {
|
||||
setCurrentReference({
|
||||
@@ -589,7 +612,62 @@ const ViewAllResults = (props) => {
|
||||
) &&
|
||||
deleteCaseItem(
|
||||
props.accountDetails.containerID,
|
||||
item.ticketnumber
|
||||
item.pinswg_name
|
||||
);
|
||||
}}
|
||||
>
|
||||
—
|
||||
</button>
|
||||
</dd>
|
||||
)}
|
||||
{/* {currentView.viewKey == "myRepresentations" && (
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-16 cardModuleItem ">
|
||||
<button
|
||||
title={t(
|
||||
"case:do-you-want-to-delete-case-label"
|
||||
)}
|
||||
className=" cardModuleRemoveCase govuk-link govuk-link--no-underline govuk-link--inverse "
|
||||
onClick={() => {
|
||||
confirm(
|
||||
t(
|
||||
"case:do-you-want-to-delete-case-label"
|
||||
) +
|
||||
item.pinswg_name +
|
||||
"?\n" +
|
||||
t(
|
||||
"case:do-you-want-to-delete-case-disclaimer-label"
|
||||
)
|
||||
) &&
|
||||
deleteRepItem(
|
||||
props.accountDetails.containerID,
|
||||
item.pinswg_name,
|
||||
item.repfile_name
|
||||
);
|
||||
}}
|
||||
>
|
||||
—
|
||||
</button>
|
||||
</dd>
|
||||
)} */}
|
||||
{currentView.viewKey == "watchedCases" && (
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-16 cardModuleItem ">
|
||||
<button
|
||||
title={t(
|
||||
"case:do-you-want-to-delete-case-label"
|
||||
)}
|
||||
className=" cardModuleRemoveCase govuk-link govuk-link--no-underline govuk-link--inverse "
|
||||
onClick={() => {
|
||||
confirm(
|
||||
t(
|
||||
"case:you-have-stopped-watching-label"
|
||||
) +
|
||||
item[
|
||||
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
) &&
|
||||
deleteItem(
|
||||
item.pinswg_watchlistid,
|
||||
"watchedCases"
|
||||
);
|
||||
}}
|
||||
>
|
||||
@@ -669,6 +747,86 @@ const ViewAllResults = (props) => {
|
||||
});
|
||||
};
|
||||
|
||||
const deleteRepItem = (containerID, caseID, repfile) => {
|
||||
let cookies = parseCookies();
|
||||
console.log("sssss", containerID, caseID, repfile);
|
||||
|
||||
deleteMyRepresentationsFromBlob(containerID, caseID, repfile)
|
||||
.then((data) => {
|
||||
return data;
|
||||
})
|
||||
.then(() => {
|
||||
getRepsFromBlobProxy(containerID)
|
||||
.then((data) => {
|
||||
setMyRepresentations(data);
|
||||
setMyRepresentationsDetails(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
consoleLogger(err);
|
||||
res.status(400).json(err);
|
||||
})
|
||||
.then(() => {
|
||||
setCurrentView({
|
||||
"viewName": "My Representations",
|
||||
"viewKey": "myRepresentations",
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
const deleteItem = (caseID, topThreeType) => {
|
||||
let cookies = parseCookies();
|
||||
//console.log("sssss", caseID, topThreeType);
|
||||
topThreeType == "watchedCases" &&
|
||||
deleteWatchedCases(caseID)
|
||||
.then((data) => data)
|
||||
.then(() => {
|
||||
getWatchedCasesProxy(cookies.pinsUser).then((data) => {
|
||||
setWatchedCases(data),
|
||||
getDetails(data, "myWatchedCases")
|
||||
.then((data) => {
|
||||
setWatchedCasesDetails(data);
|
||||
})
|
||||
.then(() => {
|
||||
setCurrentView({
|
||||
"viewName": "Watched Cases",
|
||||
"viewKey": "watchedCases",
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<div className="govuk-grid-row">
|
||||
@@ -882,6 +1040,21 @@ const mapDispatchToProps = (dispatch) => {
|
||||
setAwaitingSubmissionDetails: (awaitingSubmission) => {
|
||||
dispatch(setAwaitingSubmissionDetails(awaitingSubmission));
|
||||
},
|
||||
setWatchedCases: (watchedCases) => {
|
||||
dispatch(setWatchedCases(watchedCases));
|
||||
},
|
||||
setWatchedCasesDetails: (watchedCasesDetails) => {
|
||||
dispatch(setWatchedCasesDetails(watchedCasesDetails));
|
||||
},
|
||||
setWatchedCasesDetails: (watchedCasesDetails) => {
|
||||
dispatch(setWatchedCasesDetails(watchedCasesDetails));
|
||||
},
|
||||
setMyRepresentations: (myRepresentations) => {
|
||||
dispatch(setMyRepresentations(myRepresentations));
|
||||
},
|
||||
setMyRepresentationsDetails: (myRepresentationsDetails) => {
|
||||
dispatch(setMyRepresentationsDetails(myRepresentationsDetails));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ module.exports = {
|
||||
"/myportal/advancedsearchresults": ["search", "myportal"],
|
||||
"/myportal/searchresults": ["search", "myportal", "case"],
|
||||
"/myportal/case": ["case"],
|
||||
"/myportal/case/[ticketnumber]": ["case"],
|
||||
"/myportal/dnsapplications": ["search", "dnsCommon", "dnsApplications"],
|
||||
"/myportal/dnsdetails": [
|
||||
"case",
|
||||
|
||||
@@ -41,7 +41,8 @@ export default async function ApiProxy(req, res) {
|
||||
var queryUrl =
|
||||
"pinswg_dnses?$filter=pinswg_name eq '" +
|
||||
caseReference +
|
||||
" and statuscode eq 1&$count=true";
|
||||
"&$count=true";
|
||||
//" and statuscode eq 1&$count=true";
|
||||
|
||||
queryUrl = queryUrl + getSelectQuery("pinswg_dnses");
|
||||
|
||||
|
||||
@@ -40,7 +40,8 @@ export default async function ApiProxy(req, res) {
|
||||
var queryUrl =
|
||||
"pinswg_dnses?$filter=pinswg_name eq '" +
|
||||
caseReference +
|
||||
" and statuscode eq 1&$count=true";
|
||||
"&$count=true";
|
||||
//" and statuscode eq 1&$count=true";
|
||||
|
||||
queryUrl = queryUrl + getSelectQuery("pinswg_dnses");
|
||||
|
||||
|
||||
@@ -61,7 +61,8 @@ export default async function ApiProxy(req, res) {
|
||||
primaryIdAttribute +
|
||||
"s_value eq " +
|
||||
incidentID +
|
||||
" and statuscode eq 1&$count=true";
|
||||
"&$count=true";
|
||||
//" and statuscode eq 1&$count=true";
|
||||
|
||||
queryUrl = queryUrl + getSelectQuery(appealTypeName);
|
||||
|
||||
|
||||
@@ -65,7 +65,8 @@ export default async function ApiProxy(req, res) {
|
||||
primaryIdAttribute +
|
||||
"s_value eq " +
|
||||
incidentID +
|
||||
" and statuscode eq 1&$count=true";
|
||||
"&$count=true";
|
||||
//" and statuscode eq 1&$count=true";
|
||||
|
||||
queryUrl = queryUrl + getSelectQuery(appealTypeName);
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { hashAPIPath } from "../../../actions";
|
||||
import { deleteBlobCase } from "../../../actions/azurestorage";
|
||||
|
||||
import nextConnect from "next-connect";
|
||||
import middleware from "../middleware/middleware";
|
||||
|
||||
const ApiProxy = nextConnect();
|
||||
ApiProxy.use(middleware);
|
||||
|
||||
ApiProxy.get(async (req, res) => {
|
||||
var containerName = req.query.container;
|
||||
var casefolderID = req.query.casefolderID;
|
||||
var repfile = req.query.repfile;
|
||||
var blobName = req.query.blobname;
|
||||
var checkHash = req.query.hash;
|
||||
|
||||
var checkquerypath =
|
||||
"/api/file/deleteblobrep?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
"&repfile=" +
|
||||
repfile;
|
||||
|
||||
casefolderID = casefolderID + "/" + repfile;
|
||||
|
||||
// console.log(hashAPIPath(checkquerypath), checkHash);
|
||||
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
||||
|
||||
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||
await deleteBlobCase(containerName, casefolderID).then((data) => {
|
||||
return res.status(200).json({ data: data });
|
||||
});
|
||||
// } else {
|
||||
// return res.status(400).json();
|
||||
// }
|
||||
});
|
||||
|
||||
export const config = {
|
||||
api: {
|
||||
bodyParser: false,
|
||||
},
|
||||
};
|
||||
|
||||
export default ApiProxy;
|
||||
@@ -0,0 +1,44 @@
|
||||
import {
|
||||
downloadAllProgressFiles,
|
||||
getAllProgressBlobs,
|
||||
} from "../../../actions/azurestorage";
|
||||
import _ from "lodash";
|
||||
import nextConnect from "next-connect";
|
||||
import middleware from "../middleware/middleware";
|
||||
import {
|
||||
getToken,
|
||||
azureHeaders,
|
||||
consoleLogger,
|
||||
hashAPIPath,
|
||||
} from "../../../actions";
|
||||
import axios from "axios";
|
||||
import CryptoJS from "crypto-js";
|
||||
|
||||
const WORDKEY = process.env.HASHKEY;
|
||||
|
||||
const WEBAPI_URL =
|
||||
process.env.RELAY_ROOT ||
|
||||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
||||
|
||||
const BASE_URL = process.env.API_ROOT || `http://localhost:${port}`;
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
var containerName = req.query.container;
|
||||
var checkHash = req.query.hash;
|
||||
var token = await getToken();
|
||||
|
||||
var queryUrl = "/api/file/getrepsblob?container=" + containerName;
|
||||
|
||||
return axios
|
||||
.get(
|
||||
BASE_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
azureHeaders(token.access_token)
|
||||
)
|
||||
.then(({ data }) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
consoleLogger(err);
|
||||
res.status(400).json(err);
|
||||
});
|
||||
}
|
||||
@@ -185,6 +185,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
store.dispatch(setWatchedCases(watchedCases));
|
||||
store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
|
||||
store.dispatch(setSearch(Object.entries(query)));
|
||||
store.dispatch(setLoggedInUserId(loggedInUser));
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -243,6 +244,7 @@ const mapStateToProps = (state) => {
|
||||
watchedCases: state.watchedCases,
|
||||
myRepresentations: state.myRepresentations,
|
||||
awaitingSubmission: state.awaitingSubmission,
|
||||
accountDetails: state.accountDetails,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -30,6 +30,11 @@ import {
|
||||
setWatchedCases,
|
||||
setWatchedCasesDetails,
|
||||
} from "../../store/watchedCases/action";
|
||||
import {
|
||||
setAccountDetails,
|
||||
setContainerID,
|
||||
setLoggedInUserId,
|
||||
} from "../../store/accountDetails/action";
|
||||
|
||||
import { getSession, useSession } from "next-auth/react";
|
||||
|
||||
@@ -181,6 +186,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
store.dispatch(setDNSCoords(dnsCoords));
|
||||
store.dispatch(setWatchedCases(watchedCases));
|
||||
store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
|
||||
store.dispatch(setLoggedInUserId(loggedInUser));
|
||||
|
||||
return {
|
||||
props: { showMap: showMapCheck },
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user