113 lines
3.9 KiB
JavaScript
113 lines
3.9 KiB
JavaScript
import { useSession } from "next-auth/react";
|
|
import useTranslation from "next-translate/useTranslation";
|
|
import Head from "next/head";
|
|
import { useRouter } from "next/router";
|
|
import { connect } from "react-redux";
|
|
import Breadcrumbs from "../../components/breadcrumbs";
|
|
import CookieBanner from "../../components/cookieBanner";
|
|
import Footer from "../../components/footer";
|
|
import Header from "../../components/header";
|
|
import ViewAll from "../../components/myportal/viewall";
|
|
import NoSessionWarning from "../../components/nosession";
|
|
import TimeOut from "../../components/timeout";
|
|
import ServiceBanner from "../../components/myportal/servicebanner";
|
|
|
|
const Home = (props) => {
|
|
const { footerLinks, pages } = props;
|
|
let { t, lang } = useTranslation();
|
|
|
|
const router = useRouter();
|
|
const { locale } = router;
|
|
const { appealtypes } = router.query;
|
|
|
|
const { data: session, status } = useSession();
|
|
|
|
if (status === "loading") {
|
|
return <NoSessionWarning loading={true} />;
|
|
}
|
|
|
|
if (status === "unauthenticated") {
|
|
router.push("/auth/signin");
|
|
return <NoSessionWarning />;
|
|
}
|
|
|
|
const titleKeys = {
|
|
"myCases": t("common:mycases-viewall-title"),
|
|
|
|
"awaitingSubmissionDetails": t(
|
|
"common:awaitingsubmissiondetails-viewall-title"
|
|
),
|
|
"myRepresentations": t("common:myrepresentations-viewall-title"),
|
|
"watchedCases": t("common:watchedcases-viewall-title"),
|
|
"mySubmittedReps": t("common:mysubmittedreps-viewall-title"),
|
|
};
|
|
|
|
function whichTitle(key) {
|
|
return t(titleKeys[key]);
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<Head>
|
|
<title>
|
|
{whichTitle(router.query?.viewKey)} -{" "}
|
|
{t("common:service-name")}
|
|
</title>
|
|
</Head>
|
|
<div id="page_wrapper">
|
|
<CookieBanner />
|
|
<Header />
|
|
<div className="govuk-width-container">
|
|
<Breadcrumbs
|
|
slug={appealtypes}
|
|
currentView={props.currentView.currentView}
|
|
/>
|
|
<ServiceBanner props={props} />
|
|
<ViewAll
|
|
searchString={"View All"}
|
|
searchResultsObj={props.searchResultsObj}
|
|
currentView={props.currentView.currentView}
|
|
myCases={props.myCases}
|
|
watchedCases={props.watchedCases}
|
|
myRepresentations={props.myRepresentations}
|
|
awaitingSubmission={props.awaitingSubmission}
|
|
accountDetails={props.accountDetails}
|
|
myportal={true}
|
|
mySubmittedReps={props.mySubmittedReps}
|
|
/>
|
|
</div>
|
|
<Footer footerLinks={footerLinks} ticketnumber={props} />
|
|
</div>
|
|
<TimeOut />
|
|
</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 {
|
|
accountDetails: state.accountDetails,
|
|
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,
|
|
currentView: state.currentView,
|
|
mySubmittedReps: state.myRepresentations.mySubmittedReps,
|
|
};
|
|
};
|
|
|
|
export default connect(mapStateToProps)(Home);
|