91 lines
3.1 KiB
JavaScript
91 lines
3.1 KiB
JavaScript
import _ from "lodash";
|
|
import useTranslation from "next-translate/useTranslation";
|
|
import Head from "next/head";
|
|
import { useRouter } from "next/router";
|
|
import { connect } from "react-redux";
|
|
import { getAppealsTypes, getLPA } from "../../actions";
|
|
import { getProviderConfig } from "../../actions/govgateway";
|
|
import Breadcrumbs from "../../components/breadcrumbs";
|
|
import CookieBanner from "../../components/cookieBanner";
|
|
import CRMError from "../../components/crmError";
|
|
import Footer from "../../components/footer";
|
|
import Header from "../../components/header";
|
|
import Search from "../../components/search";
|
|
import TimeOut from "../../components/timeout";
|
|
import { setAppealType } from "../../store/appealType/action";
|
|
import { getGovGatewayConfig } from "../../store/govgateway/action";
|
|
import { setLPA } from "../../store/lpa/action";
|
|
import { wrapper } from "../../store/store";
|
|
|
|
const Home = (props) => {
|
|
const { footerLinks, pages } = props;
|
|
let { t, lang } = useTranslation();
|
|
|
|
const router = useRouter();
|
|
const { locale } = router;
|
|
const { appealtypes } = router.query;
|
|
|
|
var hasError =
|
|
_.has(props.LPAData.LPAData, "errorCode") ||
|
|
_.has(props.appealType.appealType, "errorCode")
|
|
? true
|
|
: false;
|
|
|
|
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">
|
|
<Breadcrumbs slug={appealtypes} />
|
|
{hasError ? (
|
|
<CRMError props={props} whichError="advancedSearch" />
|
|
) : (
|
|
<Search
|
|
lpadata={props.LPAData}
|
|
appealType={props.appealType}
|
|
myportal={true}
|
|
/>
|
|
)}
|
|
</div>
|
|
<Footer footerLinks={footerLinks} />
|
|
</div>
|
|
<TimeOut ggLogout={props.govGateway.config.end_session_endpoint} />
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export const getServerSideProps = wrapper.getServerSideProps(
|
|
(store) =>
|
|
async ({ query, req, res }) => {
|
|
const [appealTypeData, lpaData] = await Promise.all([
|
|
await getAppealsTypes(),
|
|
await getLPA(),
|
|
]);
|
|
const providerConfig = await getProviderConfig();
|
|
store.dispatch(getGovGatewayConfig(providerConfig));
|
|
store.dispatch(setAppealType(appealTypeData));
|
|
store.dispatch(setLPA(lpaData));
|
|
}
|
|
);
|
|
|
|
const mapStateToProps = (state) => {
|
|
return {
|
|
search: state.search,
|
|
searchResultsObj: state.searchResultsObj,
|
|
formData: state.formData,
|
|
appealType: state.appealType,
|
|
LPAData: state.LPAData,
|
|
//form: state.form,
|
|
accountDetails: state.accountDetails,
|
|
govGateway: state.govGateway,
|
|
};
|
|
};
|
|
|
|
export default connect(mapStateToProps)(Home);
|