204 lines
8.7 KiB
JavaScript
204 lines
8.7 KiB
JavaScript
import Link from "next/link";
|
|
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 Footer from "../../components/footer";
|
|
import ServiceBanner from "../../components/servicebanner";
|
|
import { useSelector, shallowEqual, connect } from "react-redux";
|
|
import { wrapper } from "../../store/store";
|
|
|
|
import { useRouter } from "next/router";
|
|
import { useState } from "react";
|
|
import useTranslation from "next-translate/useTranslation";
|
|
import { JSONPath as jsonpath } from "jsonpath-plus";
|
|
import { reduxForm, formValueSelector } from "redux-form";
|
|
|
|
import RegisterForm from "../../components/account/registerform";
|
|
import { dehashString, hashAPIPath, getIP } from "../../actions";
|
|
import { getSession, useSession, signIn, signOut } from "next-auth/react";
|
|
|
|
const Home = (props) => {
|
|
const { footerLinks, formData, loggedInUserEmail } = props;
|
|
let { t, lang } = useTranslation();
|
|
|
|
const router = useRouter();
|
|
const { locale } = router;
|
|
const { appealtypes } = router.query;
|
|
|
|
const [registerFormComplete, setRegisterFormComplete] = useState(false);
|
|
const [accountCreatedComplete, setAccountCreatedComplete] = useState(false);
|
|
|
|
return (
|
|
<div>
|
|
<Head>
|
|
<title>
|
|
{t("account:register-new-account-heading")} -{" "}
|
|
{t("common:service-name")}
|
|
</title>
|
|
</Head>
|
|
<div id="page_wrapper">
|
|
<CookieBanner />
|
|
<Header />
|
|
|
|
<div className="govuk-grid-row">
|
|
<div className="govuk-grid-column-full">
|
|
<div className="govuk-width-container">
|
|
<Breadcrumbs slug={appealtypes} />
|
|
<ServiceBanner props={props} noSignin={true} />
|
|
<main
|
|
className="govuk-main-wrapper--auto-spacing"
|
|
id="main-content"
|
|
role="main"
|
|
>
|
|
<div className="govuk-grid-row">
|
|
<div className="govuk-grid-column-two-thirds">
|
|
{registerFormComplete != true ||
|
|
accountCreatedComplete != true ? (
|
|
<h1>
|
|
{t(
|
|
"account:register-new-account-heading"
|
|
)}
|
|
</h1>
|
|
) : (
|
|
<h1>
|
|
{console.log(
|
|
props.accountDetails.accCr
|
|
)}
|
|
|
|
{props.accountDetails.accCr ===
|
|
false
|
|
? t(
|
|
"account:register-new-account-checking-label"
|
|
)
|
|
: props.accountDetails
|
|
.accCr === "created"
|
|
? t(
|
|
"account:register-new-account-status-created-label"
|
|
)
|
|
: props.accountDetails
|
|
.accCr === "exists"
|
|
? t(
|
|
"account:register-new-account-status-not-created-label"
|
|
)
|
|
: "wewer"}
|
|
</h1>
|
|
)}
|
|
<RegisterForm
|
|
props={props}
|
|
accountCreatedComplete={
|
|
accountCreatedComplete
|
|
}
|
|
registerFormComplete={
|
|
registerFormComplete
|
|
}
|
|
setRegisterFormComplete={
|
|
setRegisterFormComplete
|
|
}
|
|
setAccountCreatedComplete={
|
|
setAccountCreatedComplete
|
|
}
|
|
loggedInUserEmail={
|
|
loggedInUserEmail
|
|
}
|
|
/>
|
|
</div>
|
|
{registerFormComplete != true ||
|
|
accountCreatedComplete != true ? (
|
|
<div className="govuk-grid-column-one-third">
|
|
<h2 className="">
|
|
{t("account:help-heading")}
|
|
</h2>
|
|
|
|
<h3>
|
|
{t(
|
|
"account:help-sub-heading-1"
|
|
)}
|
|
</h3>
|
|
|
|
<p className="govuk-body">
|
|
{t("account:help-paragraph-1")}
|
|
</p>
|
|
|
|
<h3>
|
|
{t(
|
|
"account:help-sub-heading-2"
|
|
)}
|
|
</h3>
|
|
|
|
<p className="govuk-body">
|
|
{t("account:help-paragraph-2")}
|
|
</p>
|
|
|
|
<h3>
|
|
{t(
|
|
"account:help-sub-heading-3"
|
|
)}
|
|
</h3>
|
|
|
|
<p className="govuk-body">
|
|
{t("account:help-paragraph-3")}
|
|
</p>
|
|
</div>
|
|
) : (
|
|
""
|
|
)}
|
|
</div>
|
|
</main>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<Footer footerLinks={footerLinks} ticketnumber={props} />
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export const getServerSideProps = wrapper.getServerSideProps(
|
|
(store) => async (ctx) => {
|
|
const { query, req, res } = ctx;
|
|
getIP(req);
|
|
|
|
let thisSession = await getSession(ctx);
|
|
|
|
//console.log(
|
|
// "auth sess for register :",
|
|
// thisSession,
|
|
// thisSession.user.email
|
|
// );
|
|
|
|
if (!thisSession) {
|
|
console.log("not has sesssion.......");
|
|
return {
|
|
redirect: {
|
|
destination: "/auth/signin",
|
|
permanent: false,
|
|
},
|
|
};
|
|
}
|
|
|
|
return {
|
|
props: {
|
|
loggedInUserEmail: thisSession.user.email,
|
|
},
|
|
};
|
|
}
|
|
);
|
|
|
|
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,
|
|
};
|
|
};
|
|
|
|
export default connect(mapStateToProps)(Home);
|