dns searching

This commit is contained in:
2022-02-25 12:28:47 +00:00
parent 76cbd66a2f
commit f123787f1d
10 changed files with 189 additions and 127 deletions
+9
View File
@@ -190,6 +190,15 @@ export const getBasicSearchPaged = (
});
};
export const getDNSList = (searchString) => {
return axios
.get(BASE_URL + "/api/endpoint/getdnslist_api")
.then((res) => res.data)
.catch((error) => {
return error.response;
});
};
export const getBasicDNSSearch = (searchString) => {
return axios
.get(BASE_URL + "/api/endpoint/getbasicdnssearch_api")
+3 -14
View File
@@ -469,17 +469,7 @@ const Breadcrumbs = (props) => {
{router.pathname == "/dns" ? (
<>
<li className="govuk-breadcrumbs__list-item">
<Link
href={
router.locale != "en"
? router.locale + "/dns"
: "/dns"
}
>
<a className="govuk-breadcrumbs__link">
{t("dnsCommon:service-name")}
</a>
</Link>
{t("dnsCommon:service-name")}
</li>
</>
) : (
@@ -491,9 +481,8 @@ const Breadcrumbs = (props) => {
<Link
href={
router.locale == "en"
? router.locale +
"/../../dnsapplications"
: "/../../dnsapplications"
? router.locale + "/../../dns"
: "/../../dns"
}
>
<a className="govuk-breadcrumbs__link">
+6 -6
View File
@@ -13,7 +13,7 @@ const DNSLinks = (props) => {
<ul className="govuk-list">
<li>
<h3 className="govuk-heading-l govuk-!-font-size-27">
<Link href="/dns/applications">
<Link href="/dnsapplications">
<a className="govuk-link govuk-link--no-underline">
{t("dnsHome:links-applications-title")}
</a>
@@ -25,7 +25,7 @@ const DNSLinks = (props) => {
</p>
</h3>
</li>
<li>
{/* <li>
<h3 className="govuk-heading-l govuk-!-font-size-27">
<Link href="/dns/help">
<a className="govuk-link govuk-link--no-underline">
@@ -36,14 +36,14 @@ const DNSLinks = (props) => {
{t("dnsHome:links-help-intro-paragraph")}
</p>
</h3>
</li>
</li> */}
</ul>
</div>
<div className="govuk-grid-column-one-half">
<ul className="govuk-list">
<li>
<h3 className="govuk-heading-l govuk-!-font-size-27">
<Link href="/dns/application-process">
<Link href="https://gov.wales/developments-national-significance-dns-guidance">
<a className="govuk-link govuk-link--no-underline ">
{t("dnsHome:links-help-title")}
</a>
@@ -53,7 +53,7 @@ const DNSLinks = (props) => {
</p>
</h3>
</li>
<li>
{/* <li>
<h3 className="govuk-heading-l govuk-!-font-size-27">
<Link href="/dns/contact-us">
<a className="govuk-link govuk-link--no-underline">
@@ -65,7 +65,7 @@ const DNSLinks = (props) => {
{t("dnsHome:links-contactus-intro-paragraph")}
</p>
</h3>
</li>
</li> */}
</ul>
</div>
</div>
+21 -26
View File
@@ -4,9 +4,13 @@ import useTranslation from "next-translate/useTranslation";
const LatestApplications = (props) => {
let { t } = useTranslation();
const { dnsList } = props;
dnsList = dnsList.value;
let dnsListArr = dnsList.slice(0, 3);
const router = useRouter();
const { locale } = router;
return (
<div className="govuk-panel govuk-grid-column-one-third govuk-panel--latest">
<h2 className="govuk-heading-m">
@@ -15,32 +19,23 @@ const LatestApplications = (props) => {
</h2>
<div className="govuk-panel__body">
<ul className="govuk-list">
<li className="govuk-body-s ">
{" "}
<Link href="/dns/application-view">
<a href="">Brynrhyd Solar Farm</a>
</Link>
</li>
<li className="govuk-body-s ">
{" "}
<Link href="/dns/application-view">
<a href="">Brynrhyd Solar Farm</a>
</Link>
</li>
<li className="govuk-body-s ">
{" "}
<Link href="/dns/application-view">
<a href="">Brynrhyd Solar Farm</a>
</Link>
</li>
<li className="govuk-body-s ">
{" "}
<Link href="/dns/application-view">
<a href="">Brynrhyd Solar Farm</a>
</Link>
</li>
{Object.keys(dnsListArr).map((key, index) => {
return (
<li className="govuk-body-s " key={key}>
<Link
href={
"/dns/" +
dnsList[key].title
.split(" - ")[1]
.split(" ")
.join("-")
}
>
<a href="">{dnsList[key].title}</a>
</Link>
</li>
);
})}
</ul>
</div>
</div>
+24 -72
View File
@@ -1,75 +1,21 @@
import Link from "next/link";
import { useState } from "react";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import Link from "next/link";
import { useRouter } from "next/router";
import { useState } from "react";
import AutoSuggest from "react-autosuggest";
const dnsSites = [
{ id: 1, name: "30MW Energy Plant - Wrexham" },
{ id: 1, name: "Abertillery Wind Farm" },
{ id: 1, name: "Alaw Mon Solar Farm" },
{ id: 1, name: "Alwen Forest - Wind" },
{ id: 1, name: "Blackberry Lane Solar Park" },
{ id: 1, name: "Bretton Hall Solar Farm" },
{ id: 1, name: "Brynllewelyn Farm - Renewable Energy Project" },
{ id: 1, name: "Brynrhyd Solar Farm" },
{ id: 1, name: "Brynwell Farm Renewable Energy Hub" },
{ id: 1, name: "Buttington Quarry - ERF" },
{ id: 1, name: "Coed Darcy - STOR" },
{ id: 1, name: "Coity Road - STOR" },
{ id: 1, name: "Craig Y Perchyll Solar" },
{ id: 1, name: "Egnedol - Sustainable Energy" },
{ id: 1, name: "Elwy Solar Energy" },
{ id: 1, name: "Erebus - Floating Offshore Wind Demonstration Project" },
{ id: 1, name: "Felindre Road - STOR" },
{ id: 1, name: "Gaerwen Wind Farm" },
{ id: 1, name: "Garn Fach Wind Farm" },
{ id: 1, name: "Holyhead Harbour Revision Order" },
{ id: 1, name: "Holyhead Marina Harbour Revision Order" },
{ id: 1, name: "Holyhead Waterfront Regeneration Scheme HRO" },
{ id: 1, name: "Legacy Substation Gas Peaking Plant" },
{ id: 1, name: "Llantarnam - SToR" },
{ id: 1, name: "Llanwern - Solar" },
{ id: 1, name: "Lluest y Gwynt Wind Farm" },
{ id: 1, name: "Llynfi Energy Recovery Facility" },
{ id: 1, name: "Manmoel Wind Farm" },
{ id: 1, name: "Môn Solar Farm" },
{ id: 1, name: "Mor Hafren: Energy Recovery Facility" },
{ id: 1, name: "Mynydd Carn-y-Cefn Wind Farm" },
{ id: 1, name: "Mynydd Llanhilleth Wind Farm" },
{ id: 1, name: "Pancross &amp; Oaklands Solar Farm" },
{ id: 1, name: "Parc Dyffryn Solar Park" },
{ id: 1, name: "Parc Solar Traffwll" },
{ id: 1, name: "Pen March Wind Farm" },
{ id: 1, name: "Pen-y-Fan - Power Plant" },
{ id: 1, name: "Pencaerlan Solar Farm" },
{ id: 1, name: "Penderi Solar Farm" },
{ id: 1, name: "Penpergwm Solar Farm" },
{ id: 1, name: "Pentre Bach Solar Farm" },
{ id: 1, name: "Plas Power Estate Solar Farm" },
{ id: 1, name: "Project Valorous" },
{ id: 1, name: "Rhoscrowther Wind Farm" },
{ id: 1, name: "Rush Wall Solar Park Ltd" },
{ id: 1, name: "Sudbrook - Peaking Gas" },
{ id: 1, name: "TWA - Morlais Demonstration Zone" },
{ id: 1, name: "Twyn Hywel Energy Park" },
{ id: 1, name: "Tycroes Solar" },
{ id: 1, name: "Upper Ogmore - Wind Turbines" },
{ id: 1, name: "Valero - Cogeneration Facility" },
{ id: 1, name: "Vattenfall - Renewable Energy" },
{ id: 1, name: "Wauntysswg - Solar" },
{ id: 1, name: "Wentlooge - renewable energy hub" },
{ id: 1, name: "Y Bryn Wind Farm" },
];
const lowerCasedCompanies = dnsSites.map((company) => {
return {
id: company.id,
name: company.name,
};
});
const TitleContent = (props) => {
const { dnsList } = props;
const dnsSites = dnsList.value;
const lowerCasedCompanies = dnsSites.map((company) => {
return {
id: company.ticketnumber,
name: company.title,
};
});
let { t } = useTranslation();
const router = useRouter();
@@ -92,12 +38,11 @@ const TitleContent = (props) => {
<div className="govuk-panel__body">
<p className="govuk-body-s">{t("dnsHome:title-paragraph")}</p>
</div>
<div className="govuk-form-group govuk-!-margin-bottom-0 flex-container">
<div className="govuk-form-group govuk-!-margin-bottom-0 flex-container react-autosuggest">
<AutoSuggest
suggestions={suggestions}
onSuggestionsClearRequested={() => setSuggestions([])}
onSuggestionsFetchRequested={({ value }) => {
console.log(value);
setValue(value);
setSuggestions(getSuggestions(value));
}}
@@ -120,8 +65,15 @@ const TitleContent = (props) => {
}}
highlightFirstSuggestion={true}
/>
<Link href="/dns/application-view">
<a className="govuk-button govuk-!-margin-bottom-0 govuk-!-margin-left-2">
<Link
href={
"/dns/" +
(value.indexOf(" - ") > 0
? value.split(" - ")[1].split(" ").join("-")
: "")
}
>
<a className="govuk-button govuk-!-margin-bottom-0 ">
{t("dnsHome:title-application-search-button")}
</a>
</Link>
+8 -4
View File
@@ -7,7 +7,7 @@ import LatestApplications from "./homepage/latestApplications";
import DNSLinks from "./homepage/dnsLinks";
import ApplicationsForComment from "./homepage/applicationsForComment";
export default function Main({ children, pages }) {
export default function Main({ children, pages, props }) {
let { t } = useTranslation();
const router = useRouter();
@@ -22,8 +22,12 @@ export default function Main({ children, pages }) {
<div className="govuk-grid-row govuk-!-margin-bottom-0">
<div className="govuk-grid-column-full govuk-!-padding-bottom-0">
<div className="flex-container grid-row govuk-body govuk-!-margin-bottom-0 ">
<TitleContent />
<LatestApplications />
<TitleContent
dnsList={props.searchResultsObj.searchResultsObj}
/>
<LatestApplications
dnsList={props.searchResultsObj.searchResultsObj}
/>
</div>
</div>
</div>
@@ -31,7 +35,7 @@ export default function Main({ children, pages }) {
<div className="govuk-grid-column-full">
<div className="flex-container grid-row govuk-body ">
<DNSLinks />
<ApplicationsForComment />
{/* <ApplicationsForComment /> */}
</div>
</div>
</div>
-1
View File
@@ -35,7 +35,6 @@ const Header = (props) => {
"/details-about-cookies",
];
const hasContactLink = [
"/dns",
"/dns/application-process",
"/dns/help",
"/dns/contact-us",
+47
View File
@@ -0,0 +1,47 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import _ from "lodash";
import { getToken, azureHeaders } 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 token = await getToken();
var queryUrl =
"incidents?$select=_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,statuscode,ticketnumber,title &$filter=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true";
//console.log(queryUrl);
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(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);
});
}
+57 -2
View File
@@ -5,6 +5,18 @@ import CookieBanner from "../../components/cookieBanner";
import Main from "../../components/dns//main";
import Footer from "../../components/footer";
import Header from "../../components/header";
import { connect } from "react-redux";
import { wrapper } from "../../store/store";
import { getDNSList } from "../../actions";
import { getSearchDetails } from "../../components/utils";
import { setSearch } from "../../store/search/action";
import {
setSearchDetails,
setSearchResults,
} from "../../store/searchOutput/action";
import Breadcrumbs from "../../components/breadcrumbs";
const Home = (props) => {
const { footerLinks, pages } = props;
@@ -22,7 +34,8 @@ const Home = (props) => {
<CookieBanner />
<Header serviceName="Developments of National Significance" />
<div className="govuk-width-container">
<Main />
<Breadcrumbs />
<Main props={props} />
</div>
<Footer footerLinks={footerLinks} />
</div>
@@ -34,4 +47,46 @@ const Home = (props) => {
}
};
export default Home; //connect(mapStateToProps)(Home);
export const getServerSideProps = wrapper.getServerSideProps(
(store) =>
async ({ query, req, res }) => {
console.log("query-", query);
res.setHeader(
"Cache-Control",
"public, s-maxage=10, stale-while-revalidate=59"
);
let searchResultsObj = await getDNSList();
searchResultsObj =
searchResultsObj.status == 502
? {
value: [],
errorCode: searchResultsObj.status,
errorMsg: searchResultsObj.statusText,
}
: searchResultsObj;
const searchDetailsObj = await getSearchDetails(searchResultsObj);
store.dispatch(setSearchResults(searchResultsObj));
store.dispatch(setSearchDetails(searchDetailsObj));
store.dispatch(setSearch("DNS"));
}
);
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,
};
};
export default connect(mapStateToProps)(Home);
+14 -2
View File
@@ -1468,10 +1468,22 @@ ul#sharePageLinks.active {
}
// dns autocomplete search
.react-autosuggest {
.govuk-button {
@media screen and (min-width: 768px) {
margin-left: 10px;
}
}
}
.react-autosuggest__container {
position: relative;
width: 50%;
width: 100%;
margin-bottom: 20px;
@media screen and (min-width: 768px) {
width: 50%;
margin-bottom: 0px;
}
}
.react-autosuggest__input {