76 lines
2.4 KiB
JavaScript
76 lines
2.4 KiB
JavaScript
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 ViewAll from "../components/viewall";
|
|
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 Cookies from "cookies";
|
|
import { useRouter } from "next/router";
|
|
import useTranslation from "next-translate/useTranslation";
|
|
|
|
import { setSearch, getSearchObj } from "../store/search/action";
|
|
import {
|
|
setSearchResults,
|
|
getSearchResultsObj,
|
|
} from "../store/searchOutput/action";
|
|
import { getBasicSearch } from "../actions";
|
|
|
|
const Home = (props) => {
|
|
const { footerLinks, pages } = props;
|
|
let { t, lang } = useTranslation();
|
|
|
|
const router = useRouter();
|
|
const { locale } = router;
|
|
const { appealtypes } = router.query;
|
|
|
|
return (
|
|
<div>
|
|
<Head>
|
|
<title>
|
|
{t("search:page-title")} - {t("common:service-name")}
|
|
</title>
|
|
</Head>
|
|
<div id="page_wrapper">
|
|
<CookieBanner />
|
|
<Header courseName={t("common:service-name")} />
|
|
<div className="govuk-width-container">
|
|
<Banner />
|
|
<Breadcrumbs slug={appealtypes} />
|
|
<ViewAll
|
|
searchString={"View All"}
|
|
searchResultsObj={props.searchResultsObj}
|
|
currentView={props.currentView.currentView}
|
|
/>
|
|
</div>
|
|
<Footer footerLinks={footerLinks} />
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export const getServerSideProps = wrapper.getServerSideProps(
|
|
(store) =>
|
|
async ({ req, res }) => {
|
|
const searchResultsObj = (await getBasicSearch("View All")) || null;
|
|
store.dispatch(setSearchResults(searchResultsObj));
|
|
store.dispatch(setSearch("View All"));
|
|
}
|
|
);
|
|
|
|
const mapStateToProps = (state) => {
|
|
return {
|
|
search: state.search,
|
|
searchResultsObj: state.searchResultsObj,
|
|
form: state.form,
|
|
currentView: state.currentView,
|
|
};
|
|
};
|
|
|
|
export default connect(mapStateToProps)(Home);
|