dns url redirects to case
This commit is contained in:
+1
-1
@@ -46,7 +46,7 @@ RELAYPATH = "prod-pedw-hc"
|
|||||||
|
|
||||||
GOOGLE_TAG_MANAGER = GTM-T78CBC3
|
GOOGLE_TAG_MANAGER = GTM-T78CBC3
|
||||||
SHOWLOGIN = "true"
|
SHOWLOGIN = "true"
|
||||||
SHOWREPRESENTATIONS = "false"
|
SHOWREPRESENTATIONS = false
|
||||||
//BASIC_AUTH_CREDENTIALS = pinswg:password|pinswg2:password2
|
//BASIC_AUTH_CREDENTIALS = pinswg:password|pinswg2:password2
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -145,6 +145,22 @@ export const getBasicSearch = (searchString) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getBasicDNSURLSearch = (searchString) => {
|
||||||
|
return axios
|
||||||
|
.get(
|
||||||
|
BASE_URL +
|
||||||
|
"/api/endpoint/getbasicdnsurlsearch_api?searchString=" +
|
||||||
|
searchString
|
||||||
|
)
|
||||||
|
.then((res) => {
|
||||||
|
return res.data;
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.log(error);
|
||||||
|
return error.response;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const getBasicSearchPaged = (
|
export const getBasicSearchPaged = (
|
||||||
searchString,
|
searchString,
|
||||||
pageNumber,
|
pageNumber,
|
||||||
|
|||||||
+33
-12
@@ -13,6 +13,8 @@ const Breadcrumbs = (props) => {
|
|||||||
|
|
||||||
let { t } = useTranslation();
|
let { t } = useTranslation();
|
||||||
|
|
||||||
|
console.log("asdadad", slug);
|
||||||
|
|
||||||
function Breadcrumb() {
|
function Breadcrumb() {
|
||||||
if (slug) {
|
if (slug) {
|
||||||
var coursePageURL = appealType + "/" + slug;
|
var coursePageURL = appealType + "/" + slug;
|
||||||
@@ -64,17 +66,9 @@ const Breadcrumbs = (props) => {
|
|||||||
</Link>
|
</Link>
|
||||||
</li> */}
|
</li> */}
|
||||||
<li className="govuk-breadcrumbs__list-item">
|
<li className="govuk-breadcrumbs__list-item">
|
||||||
<Link
|
<Link href={"/"}>
|
||||||
href={
|
|
||||||
router.pathname.includes("/dns/")
|
|
||||||
? "/dns"
|
|
||||||
: "/"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<a className="govuk-breadcrumbs__link">
|
<a className="govuk-breadcrumbs__link">
|
||||||
{router.pathname.includes("/dns/")
|
{t("common:service-name-breadcrumb")}
|
||||||
? t("dnsCommon:service-name")
|
|
||||||
: t("common:service-name-breadcrumb")}
|
|
||||||
</a>
|
</a>
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
@@ -493,6 +487,33 @@ const Breadcrumbs = (props) => {
|
|||||||
) : (
|
) : (
|
||||||
""
|
""
|
||||||
)}
|
)}
|
||||||
|
{router.pathname == "/dns/[developmentName]" ? (
|
||||||
|
<>
|
||||||
|
<li className="govuk-breadcrumbs__list-item">
|
||||||
|
<Link
|
||||||
|
href={
|
||||||
|
router.locale == "en"
|
||||||
|
? router.locale +
|
||||||
|
"/../../dnsapplications"
|
||||||
|
: "/../../dnsapplications"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<a className="govuk-breadcrumbs__link">
|
||||||
|
{t("dnsCommon:service-name")}
|
||||||
|
</a>
|
||||||
|
</Link>
|
||||||
|
</li>
|
||||||
|
<li className="govuk-breadcrumbs__list-item">
|
||||||
|
{t("common:breadcrumb-case-reference")}:{" "}
|
||||||
|
{
|
||||||
|
props.props.currentView.caseReference
|
||||||
|
.currentReference
|
||||||
|
}
|
||||||
|
</li>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
""
|
||||||
|
)}
|
||||||
{router.pathname == "/dnsapplications" ? (
|
{router.pathname == "/dnsapplications" ? (
|
||||||
<>
|
<>
|
||||||
<li className="govuk-breadcrumbs__list-item">
|
<li className="govuk-breadcrumbs__list-item">
|
||||||
@@ -628,7 +649,7 @@ const Breadcrumbs = (props) => {
|
|||||||
) : (
|
) : (
|
||||||
""
|
""
|
||||||
)}
|
)}
|
||||||
{!_.isEmpty(slug) ? (
|
{/* {!_.isEmpty(slug) ? (
|
||||||
<>
|
<>
|
||||||
<li className="govuk-breadcrumbs__list-item">
|
<li className="govuk-breadcrumbs__list-item">
|
||||||
<Link
|
<Link
|
||||||
@@ -662,7 +683,7 @@ const Breadcrumbs = (props) => {
|
|||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
""
|
""
|
||||||
)}
|
)} */}
|
||||||
|
|
||||||
<Breadcrumb />
|
<Breadcrumb />
|
||||||
</ol>
|
</ol>
|
||||||
|
|||||||
@@ -63,7 +63,11 @@ const CaseSummary = (props) => {
|
|||||||
setCurrentReference,
|
setCurrentReference,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const noRepresentationLink = ["/case", "/dnsdetails"];
|
const noRepresentationLink = [
|
||||||
|
"/case",
|
||||||
|
"/dnsdetails",
|
||||||
|
"/dns/[developmentName]",
|
||||||
|
];
|
||||||
|
|
||||||
let setCaseQueryObj = props[currentType];
|
let setCaseQueryObj = props[currentType];
|
||||||
let setCaseDetailsObj = props[currentType + "Details"];
|
let setCaseDetailsObj = props[currentType + "Details"];
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ module.exports = {
|
|||||||
"/newappeal": ["newappeal"],
|
"/newappeal": ["newappeal"],
|
||||||
"/newappeal/*": ["newappeal"],
|
"/newappeal/*": ["newappeal"],
|
||||||
"/newappeal/selectappeal": ["newappeal"],
|
"/newappeal/selectappeal": ["newappeal"],
|
||||||
"/dns/*": ["dnsCommon"],
|
"/dns/*": ["dnsCommon", "case", "common"],
|
||||||
|
"/dns/[developmentName]": ["dnsCommon", "case", "common"],
|
||||||
"/dns": ["dnsCommon", "dnsHome"],
|
"/dns": ["dnsCommon", "dnsHome"],
|
||||||
"/dns/applications": ["dnsCommon", "dnsApplications"],
|
"/dns/applications": ["dnsCommon", "dnsApplications"],
|
||||||
"/dns/application-view": ["dnsCommon", "dnsApplicationView"],
|
"/dns/application-view": ["dnsCommon", "dnsApplicationView"],
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import axios from "axios";
|
||||||
|
import CryptoJS from "crypto-js";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { getToken, azureHeadersPaged } from "../../../actions";
|
||||||
|
|
||||||
|
const WORDKEY = process.env.HASHKEY;
|
||||||
|
|
||||||
|
const WEBAPI_URL =
|
||||||
|
process.env.RELAY_ROOT ||
|
||||||
|
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
||||||
|
|
||||||
|
const hashAPIPath = (queryPath) => {
|
||||||
|
var hashlink = CryptoJS.HmacSHA256(
|
||||||
|
queryPath,
|
||||||
|
CryptoJS.enc.Hex.parse(WORDKEY)
|
||||||
|
);
|
||||||
|
hashlink = hashlink.toString(CryptoJS.enc.Hex);
|
||||||
|
|
||||||
|
//return "&hash=" + hashlink;
|
||||||
|
|
||||||
|
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default async function ApiProxy(req, res) {
|
||||||
|
var searchString = req.query.searchString;
|
||||||
|
var token = await getToken();
|
||||||
|
|
||||||
|
var queryUrl =
|
||||||
|
"incidents?$select=description,numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=(contains(title, '" +
|
||||||
|
searchString +
|
||||||
|
"') or contains(ticketnumber, '" +
|
||||||
|
searchString +
|
||||||
|
"')) and pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true";
|
||||||
|
|
||||||
|
// console.log("basic search ", queryUrl);
|
||||||
|
|
||||||
|
var apiResponse = _.isEmpty(req.query)
|
||||||
|
? res.status(400).json()
|
||||||
|
: searchString.length > 0
|
||||||
|
? axios
|
||||||
|
.get(
|
||||||
|
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||||
|
azureHeadersPaged(token.access_token)
|
||||||
|
)
|
||||||
|
.then(({ data }) => {
|
||||||
|
var dataStr;
|
||||||
|
_.has(data, "@odata.nextLink") == true &&
|
||||||
|
((dataStr = JSON.stringify(data["@odata.nextLink"])),
|
||||||
|
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
|
||||||
|
res.status(200).json(data);
|
||||||
|
})
|
||||||
|
.catch(({ err }) => {
|
||||||
|
res.status(400).json(err);
|
||||||
|
})
|
||||||
|
: res.status(400).json();
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
// 404.js
|
||||||
|
import useTranslation from "next-translate/useTranslation";
|
||||||
|
import Head from "next/head";
|
||||||
|
import Link from "next/link";
|
||||||
|
import CookieBanner from "../components/cookieBanner";
|
||||||
|
import Footer from "../components/footer";
|
||||||
|
import Header from "../components/header";
|
||||||
|
|
||||||
|
const FourOhFour = (props) => {
|
||||||
|
let { t, lang } = useTranslation();
|
||||||
|
const { footerLinks, pages } = props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Head>
|
||||||
|
<title>
|
||||||
|
{t("common:404-not-found-title")} -{" "}
|
||||||
|
{t("common:service-name")}
|
||||||
|
</title>
|
||||||
|
</Head>
|
||||||
|
<div id="page_wrapper">
|
||||||
|
<CookieBanner />
|
||||||
|
<Header courseName={t("common:service-name")} />
|
||||||
|
<div className="govuk-width-container govuk-!-padding-bottom-9">
|
||||||
|
<main className="govuk-main-wrapper govuk-!-padding-top-9 govuk-!-padding-bottom-9">
|
||||||
|
<div className="govuk-grid-row">
|
||||||
|
<div className="govuk-grid-column-full ">
|
||||||
|
<h1>
|
||||||
|
Development of National Signifcance not
|
||||||
|
found
|
||||||
|
</h1>
|
||||||
|
<Link href="/">
|
||||||
|
<a>{t("common:404-not-found-link")}</a>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
<Footer footerLinks={footerLinks} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default FourOhFour;
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
import useTranslation from "next-translate/useTranslation";
|
||||||
|
import Head from "next/head";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
import { getBasicDNSURLSearch } 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";
|
||||||
|
|
||||||
|
const CaseHome = (props) => {
|
||||||
|
const { footerLinks, pages } = props;
|
||||||
|
let { t, lang } = useTranslation();
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
const { locale } = router;
|
||||||
|
const { developmentName } = router.query;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Head>
|
||||||
|
<title>
|
||||||
|
Reference:{" "}
|
||||||
|
{props.currentView.caseReference.currentReference}{" "}
|
||||||
|
Developments of National Significance
|
||||||
|
</title>
|
||||||
|
</Head>
|
||||||
|
<div id="page_wrapper">
|
||||||
|
<CookieBanner />
|
||||||
|
<Header serviceName="Developments of National Significance" />
|
||||||
|
<div className="govuk-width-container">
|
||||||
|
<Breadcrumbs slug={developmentName} props={props} />
|
||||||
|
|
||||||
|
<Case
|
||||||
|
props={props}
|
||||||
|
myCases={props.myCases.myCases}
|
||||||
|
myCasesDetails={props.myCases.myCasesDetails}
|
||||||
|
searchResultsObj={
|
||||||
|
props.searchResultsObj.searchResultsObj
|
||||||
|
}
|
||||||
|
searchDetailsObj={
|
||||||
|
props.searchResultsObj.searchDetailsObj
|
||||||
|
}
|
||||||
|
documentDetailsObj={
|
||||||
|
props.searchResultsObj.documentDetailsObj
|
||||||
|
}
|
||||||
|
documentHistoryObj={
|
||||||
|
props.searchResultsObj.documentHistoryObj
|
||||||
|
}
|
||||||
|
myRepresentations={
|
||||||
|
props.myRepresentations.myRepresentations
|
||||||
|
}
|
||||||
|
watchedCases={props.watchedCases.watchedCases}
|
||||||
|
watchedCasesDetails={
|
||||||
|
props.watchedCases.watchedCasesDetails
|
||||||
|
}
|
||||||
|
awaitingSubmission={
|
||||||
|
props.awaitingSubmission.awaitingSubmission
|
||||||
|
}
|
||||||
|
caseReference={
|
||||||
|
props.currentView.caseReference.currentReference
|
||||||
|
}
|
||||||
|
currentType={
|
||||||
|
props.currentView.caseReference.currentType
|
||||||
|
}
|
||||||
|
appealTypeID={
|
||||||
|
props.currentView.caseReference.appealType
|
||||||
|
}
|
||||||
|
incidentid={props.currentView.caseReference.incidentid}
|
||||||
|
representationsObj={
|
||||||
|
props.searchResultsObj.representationsObj
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Footer footerLinks={footerLinks} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getServerSideProps = wrapper.getServerSideProps(
|
||||||
|
(store) => async (ctx) => {
|
||||||
|
const { query, req, res } = ctx;
|
||||||
|
const { cookies } = req;
|
||||||
|
|
||||||
|
console.log(cookies);
|
||||||
|
console.log("the query", query.developmentName);
|
||||||
|
let loggedInUser = cookies.pinsUser;
|
||||||
|
|
||||||
|
let developmentQuery = query.developmentName.split("-").join(" ");
|
||||||
|
|
||||||
|
const searchResultsObj = await getBasicDNSURLSearch(developmentQuery);
|
||||||
|
const searchDetailsObj = await getSearchDetails(searchResultsObj);
|
||||||
|
|
||||||
|
store.dispatch(setSearchResults(searchResultsObj));
|
||||||
|
store.dispatch(setSearchDetails(searchDetailsObj));
|
||||||
|
store.dispatch(setSearch(developmentQuery));
|
||||||
|
|
||||||
|
// console.log({
|
||||||
|
// "currentReference": searchResultsObj.value[0].title,
|
||||||
|
// "currentType": "searchResultsObj",
|
||||||
|
// "incidentid": searchResultsObj.value[0].incidentid,
|
||||||
|
// "appealType": searchResultsObj.value[0].pinswg_appealcasetype,
|
||||||
|
// });
|
||||||
|
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",
|
||||||
|
permanent: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
store.dispatch(
|
||||||
|
setCurrentReference({
|
||||||
|
"currentReference": searchResultsObj.value[0].title,
|
||||||
|
"currentType": "searchResultsObj",
|
||||||
|
"incidentid": searchResultsObj.value[0].incidentid,
|
||||||
|
"appealType":
|
||||||
|
searchResultsObj.value[0].pinswg_appealcasetype,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// console.log(searchResultsObj);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const mapStateToProps = (state) => {
|
||||||
|
return {
|
||||||
|
currentView: state.currentView,
|
||||||
|
search: state.search,
|
||||||
|
searchResultsObj: state.searchResultsObj,
|
||||||
|
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);
|
||||||
+5
-13
@@ -1,18 +1,10 @@
|
|||||||
import _ from "lodash";
|
|
||||||
import Head from "next/head";
|
|
||||||
import Header from "../../components/header";
|
|
||||||
import Banner from "../../components/banner";
|
|
||||||
import CookieBanner from "../../components/cookieBanner";
|
|
||||||
import Breadcrumbs from "../../components/breadcrumbs";
|
|
||||||
import Footer from "../../components/footer";
|
|
||||||
import Errorpage from "../../components/errorpage";
|
|
||||||
import styles from "../../styles/Home.module.css";
|
|
||||||
import { useSelector, shallowEqual, connect } from "react-redux";
|
|
||||||
import { wrapper } from "../../store/store";
|
|
||||||
|
|
||||||
import { useRouter } from "next/router";
|
|
||||||
import useTranslation from "next-translate/useTranslation";
|
import useTranslation from "next-translate/useTranslation";
|
||||||
|
import Head from "next/head";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
|
import CookieBanner from "../../components/cookieBanner";
|
||||||
import Main from "../../components/dns//main";
|
import Main from "../../components/dns//main";
|
||||||
|
import Footer from "../../components/footer";
|
||||||
|
import Header from "../../components/header";
|
||||||
|
|
||||||
const Home = (props) => {
|
const Home = (props) => {
|
||||||
const { footerLinks, pages } = props;
|
const { footerLinks, pages } = props;
|
||||||
|
|||||||
+3
-3
@@ -108,9 +108,9 @@ const makeStore = ({ isServer }) => {
|
|||||||
const persistConfig = {
|
const persistConfig = {
|
||||||
key: "acp",
|
key: "acp",
|
||||||
whitelist: [
|
whitelist: [
|
||||||
"currentView",
|
// "currentView",
|
||||||
"search",
|
// "search",
|
||||||
"searchResultsObj",
|
// "searchResultsObj",
|
||||||
"formData",
|
"formData",
|
||||||
"appealType",
|
"appealType",
|
||||||
"LPAData",
|
"LPAData",
|
||||||
|
|||||||
Reference in New Issue
Block a user