140 lines
4.8 KiB
JavaScript
140 lines
4.8 KiB
JavaScript
import _ from "lodash";
|
|
import { useState, useEffect, useRef } from "react";
|
|
import Head from "next/head";
|
|
import Header from "../components/header";
|
|
import ServiceBanner from "../components/servicebanner";
|
|
import CookieBanner from "../components/cookieBanner";
|
|
import Breadcrumbs from "../components/breadcrumbs";
|
|
import Main from "../components/main";
|
|
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 { getIncidents } from "../actions";
|
|
import { parseCookies } from "nookies";
|
|
|
|
import { getProviderConfig, getGGToken } from "../actions/govgateway";
|
|
import { getGovGatewayConfig } from "../store/govgateway/action";
|
|
|
|
const Home = (props) => {
|
|
const { footerLinks, pages, showLogin } = props;
|
|
let { t, lang } = useTranslation();
|
|
|
|
const router = useRouter();
|
|
const { locale } = router;
|
|
|
|
return (
|
|
<div>
|
|
<Head>
|
|
<title>{t("common:service-name")}</title>
|
|
{/* Language by default is EN, if multilingual site this will need updated */}
|
|
<meta
|
|
key="og:locale"
|
|
property="og:locale"
|
|
content={router.locale}
|
|
/>
|
|
{/* If they have a Twitter Handle, include the meta details below */}
|
|
<meta
|
|
key="og:site_name"
|
|
property="og:site_name"
|
|
content={t("common:service-name")}
|
|
/>
|
|
<meta
|
|
key="twitter:site"
|
|
property="twitter:site"
|
|
content="@UKGovWales"
|
|
/>
|
|
|
|
<meta
|
|
name="description"
|
|
content={t("common:service-description")}
|
|
/>
|
|
<meta
|
|
property="og:site_name"
|
|
content={t("common:gov-wales-label")}
|
|
/>
|
|
<meta property="og:type" content="website" />
|
|
<meta property="og:url" content={t("common:gov-wales-link")} />
|
|
<meta
|
|
property="og:image"
|
|
content="https://gov.wales/themes/custom/govwales/images/content/og-global-1200.png"
|
|
/>
|
|
<meta name="twitter:card" content="summary" />
|
|
<meta
|
|
name="twitter:title"
|
|
content={t("common:gov-wales-label")}
|
|
/>
|
|
<meta
|
|
name="twitter:url"
|
|
content={t("common:gov-wales-link") + router.pathname}
|
|
/>
|
|
<meta
|
|
name="twitter:image"
|
|
content="https://gov.wales/themes/custom/govwales/images/content/og-global-120.png"
|
|
/>
|
|
</Head>
|
|
<div id="page_wrapper">
|
|
<CookieBanner />
|
|
<Header courseName="Appeals Casework Portal" />
|
|
<div className="govuk-width-container">
|
|
<ServiceBanner />
|
|
<Main pages={pages} showLogin={showLogin} />
|
|
</div>
|
|
<Footer footerLinks={footerLinks} />
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export const getServerSideProps = wrapper.getServerSideProps(
|
|
(store) => async (ctx) => {
|
|
const { query, req, res } = ctx;
|
|
|
|
console.log(query.code);
|
|
|
|
const showLoginCheck = process.env.SHOWLOGIN || false;
|
|
const hasLoginCode = typeof query.code != "undefined";
|
|
|
|
console.log("Show login module: ", showLoginCheck);
|
|
|
|
let providerConfig = await getProviderConfig();
|
|
|
|
console.log(providerConfig.token_endpoint);
|
|
|
|
store.dispatch(getGovGatewayConfig(providerConfig));
|
|
|
|
if (hasLoginCode == true) {
|
|
let ggToken = await getGGToken(
|
|
providerConfig.token_endpoint,
|
|
query.code,
|
|
process.env.GG_REDIRECT_URI
|
|
);
|
|
console.log(ggToken);
|
|
}
|
|
|
|
return {
|
|
props: { showLogin: showLoginCheck },
|
|
};
|
|
}
|
|
);
|
|
|
|
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,
|
|
govGateway: state.govGateway,
|
|
};
|
|
};
|
|
export default connect(mapStateToProps)(Home);
|