dns searching
This commit is contained in:
+57
-2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user