221 lines
7.5 KiB
JavaScript
221 lines
7.5 KiB
JavaScript
import useTranslation from "next-translate/useTranslation";
|
|
import Head from "next/head";
|
|
import { useEffect } from "react";
|
|
|
|
import { useRouter } from "next/router";
|
|
import { connect, useDispatch } from "react-redux";
|
|
import Breadcrumbs from "../../components/breadcrumbs";
|
|
import CookieBanner from "../../components/cookieBanner";
|
|
import Footer from "../../components/footer";
|
|
import Header from "../../components/header";
|
|
import Case from "../../components/representation";
|
|
import { wrapper } from "../../store/store";
|
|
import { getSession, useSession, signIn } from "next-auth/react";
|
|
import {
|
|
consoleLogger,
|
|
getPersonalAccount,
|
|
getPortalLogin,
|
|
} from "../../actions";
|
|
import {
|
|
setRepresentationCapacity,
|
|
setRepresentationSubmit,
|
|
setSubmitBack,
|
|
setRepresentationSubmitConfirmation,
|
|
} from "../../store/currentView/action";
|
|
import {
|
|
setAccountDetails,
|
|
setContainerID,
|
|
setLoggedInUserId,
|
|
} from "../../store/accountDetails/action";
|
|
|
|
import NoSessionWarning from "../../components/nosession";
|
|
|
|
const Home = (props) => {
|
|
const { footerLinks, pages } = props;
|
|
let { t, lang } = useTranslation();
|
|
|
|
const router = useRouter();
|
|
const { locale } = router;
|
|
const { appealtypes } = router.query;
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
// useEffect(() => {
|
|
// const updateAccountStore = async () => {
|
|
// const thisSession = await getSession();
|
|
|
|
// if (thisSession) {
|
|
// let loggedInUser = await getPortalLogin(thisSession.user.email);
|
|
// dispatch(
|
|
// setAccountDetails(
|
|
// await getPersonalAccount(
|
|
// loggedInUser.value[0].contactid
|
|
// )
|
|
// )
|
|
// );
|
|
// dispatch(setContainerID(thisSession.user.id));
|
|
|
|
// //dispatch(setRepresentationSubmit(true));
|
|
// }
|
|
// };
|
|
// updateAccountStore();
|
|
// }, [dispatch]);
|
|
|
|
const { data: session, status } = useSession();
|
|
|
|
if (status === "loading") {
|
|
return <NoSessionWarning loading={true} />;
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<Head>
|
|
<title>
|
|
{t("case:page-title")} - {t("common:service-name")}
|
|
</title>
|
|
<>
|
|
<link
|
|
rel="canonical"
|
|
href={t("common:gov-wales-link") + router.asPath}
|
|
/>
|
|
<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:title" content={t("case:page-title")} />
|
|
<meta
|
|
property="og:description"
|
|
content={t("common:service-description")}
|
|
/>
|
|
<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.asPath}
|
|
/>
|
|
<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={t("common:service-name")} />
|
|
<div className="govuk-width-container">
|
|
<Breadcrumbs slug={appealtypes} props={props} />
|
|
<Case
|
|
myCases={props.myCases.myCases}
|
|
searchResultsObj={
|
|
props.searchResultsObj.searchResultsObj
|
|
}
|
|
searchDetailsObj={
|
|
props.searchResultsObj.searchDetailsObj
|
|
}
|
|
myRepresentations={
|
|
props.myRepresentations.myRepresentations
|
|
}
|
|
watchedCases={props.watchedCases.watchedCases}
|
|
awaitingSubmission={
|
|
props.awaitingSubmission.awaitingSubmission
|
|
}
|
|
caseReference={
|
|
props.currentView.caseReference.currentReference
|
|
}
|
|
currentType={
|
|
props.currentView.caseReference.currentType
|
|
}
|
|
props={props}
|
|
/>
|
|
</div>
|
|
<Footer footerLinks={footerLinks} />
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
// export const getServerSideProps = wrapper.getServerSideProps(
|
|
// (store) => async (ctx) => {
|
|
// const { query, req, res } = ctx;
|
|
// console.log("The query", query);
|
|
|
|
// const { cookies } = req;
|
|
|
|
// let loggedInUser = cookies.pinsUser;
|
|
|
|
// let thisSession = await getSession(ctx);
|
|
|
|
// console.log(loggedInUser, thisSession);
|
|
|
|
// const accountDetails = await getPersonalAccount(loggedInUser);
|
|
// store.dispatch(setAccountDetails(accountDetails));
|
|
|
|
// return {
|
|
// props: {
|
|
// containerID: thisSession.user.id,
|
|
// },
|
|
// };
|
|
// }
|
|
// );
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
return {
|
|
setAccountDetails: (loggedInUser) => {
|
|
dispatch(setAccountDetails(loggedInUser));
|
|
},
|
|
};
|
|
};
|
|
|
|
const mapStateToProps = (state) => {
|
|
//console.log(state);
|
|
|
|
return {
|
|
accountDetails: state.accountDetails,
|
|
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, mapDispatchToProps)(Home);
|