diff --git a/components/account/changepassword.js b/components/account/changepassword.js index 54bf59ee..20d173a9 100644 --- a/components/account/changepassword.js +++ b/components/account/changepassword.js @@ -1,3 +1,4 @@ +import Link from "next/link"; import _ from "lodash"; import React, { useState } from "react"; import { useRouter } from "next/router"; @@ -9,17 +10,6 @@ import { getFormSubmitErrors, } from "redux-form"; import { useDispatch, useSelector, shallowEqual, connect } from "react-redux"; -import { - Textfield, - DateField, - DateFieldPicker, - YesNofield, - PickList, - MultiLinefield, - NumericField, - ReadOnlyfield, - DecimalField, -} from "../elements"; const RenderTextfield = ({ id, @@ -69,7 +59,14 @@ const RenderTextfield = ({ }; const ChangePassword = (props) => { - const { footerLinks, pages, handleSubmit, value } = props; + const { + footerLinks, + pages, + handleSubmit, + value, + setPasswordUpdated, + passwordUpdated, + } = props; let { t, lang } = useTranslation(); const router = useRouter(); @@ -78,74 +75,65 @@ const ChangePassword = (props) => { let errorsobj = {}; const onHandleSubmit = (values) => { - console.log(values); + setPasswordUpdated(true); }; const required = (value) => (value ? undefined : "Is required"); - const matchInput = (input, allInputs) => { - return input === allInputs.password - ? undefined - : "Passwords do not match"; - }; + const passwordsMustMatch = (value, allValues) => + value !== allValues.newpassword ? "Passwords do not match" : undefined; - const email = (value) => - value && !/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(value) - ? "Invalid email address" - : undefined; - const phoneNumber = (value) => - value && - !/^(?:(?:\(?(?:0(?:0|11)\)?[\s-]?\(?|\+)44\)?[\s-]?(?:\(?0\)?[\s-]?)?)|(?:\(?0))(?:(?:\d{5}\)?[\s-]?\d{4,5})|(?:\d{4}\)?[\s-]?(?:\d{5}|\d{3}[\s-]?\d{3}))|(?:\d{3}\)?[\s-]?\d{3}[\s-]?\d{3,4})|(?:\d{2}\)?[\s-]?\d{4}[\s-]?\d{4}))(?:[\s-]?(?:x|ext\.?|\#)\d{3,4})?$/i.test( - value - ) - ? "Invalid phone number" + const minLength = (min) => (value) => + value && value.length < min + ? `Must be at least ${min} characters` : undefined; const [hasErrors, setHasErrors] = useState(""); return ( <> - {/* {hasErrors == true ? ( - - ) : ( - "" - )} */} -
-
- - -
+ {passwordUpdated != true ? ( + +
+ + +
-
- -
-
+
+ +
+ + ) : ( + <> +

+ + Go to My Portal + +

+ + )} ); }; diff --git a/components/account/personaldetails.js b/components/account/personaldetails.js index f88fc88b..78701686 100644 --- a/components/account/personaldetails.js +++ b/components/account/personaldetails.js @@ -10,18 +10,9 @@ import { getFormSubmitErrors, } from "redux-form"; import { useDispatch, useSelector, shallowEqual, connect } from "react-redux"; -import { - Textfield, - DateField, - DateFieldPicker, - YesNofield, - PickList, - MultiLinefield, - NumericField, - ReadOnlyfield, - DecimalField, -} from "../elements"; + import BuildCheckPersonalDetails from "./personaldetailsCheck"; +import PersonalDetailsComplete from "./personaldetailsComplete"; const RenderTextfield = ({ id, @@ -71,7 +62,12 @@ const RenderTextfield = ({ }; const PersonalDetails = (props) => { - const { footerLinks, pages, handleSubmit, value } = props; + const { + handleSubmit, + value, + setPersonalDetailsComplete, + setAccountUpdatedComplete, + } = props; let { t, lang } = useTranslation(); const router = useRouter(); @@ -79,10 +75,6 @@ const PersonalDetails = (props) => { let errorsobj = {}; - const onHandleSubmit = (values) => { - console.log(values); - }; - const required = (value) => (value ? undefined : "Is required"); const email = (value) => value && !/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(value) @@ -98,178 +90,155 @@ const PersonalDetails = (props) => { const [hasErrors, setHasErrors] = useState(""); - const [personalDetailsComplete, setPersonalDetailsComplete] = - useState(false); + const onHandleSubmit = (values) => { + setPersonalDetailsComplete(true); + }; return ( <> - {/* {hasErrors == true ? ( - - ) : ( - "" - )} */} + {props.accountUpdatedComplete != true ? ( + props.personalDetailsComplete == false ? ( +
+
+ +

+ About you +

+
+ + + + - {personalDetailsComplete == false ? ( - -
- -

- About you -

-
- - - - + +
+
+ +

+ What is your address? +

+
- -
-
- -

- What is your address? -

-
- - - - - - -
-
- -
- - ) : ( - <> - -
- - - - + + + + +
+
+
- + Continue + + + + ) : ( + <> + + + ) + ) : ( + )} ); @@ -296,16 +265,20 @@ const mapDispatchToProps = (dispatch) => { const selector = formValueSelector("personalDetailsForm"); // <-- same as form name -export default connect(mapStateToProps, mapDispatchToProps, (state) => ({ - initialValues: state.accountDetails.accountDetails.data, - search: state.search, - searchResultsObj: state.searchResultsObj, - formData: state.formData, - appealType: state.appealType, - accountDetails: state.accountDetails, - form: state.form, +export default connect( + mapStateToProps, + mapDispatchToProps + //, (state) => ({ + // initialValues: state.accountDetails.accountDetails.data, + // // search: state.search, + // searchResultsObj: state.searchResultsObj, + // formData: state.formData, + // appealType: state.appealType, + // accountDetails: state.accountDetails, + // form: state.form, // pull initial values from account reducer -}))( + //}) +)( reduxForm({ form: "personalDetailsForm", enableReinitialize: true, // this is needed!! diff --git a/components/account/personaldetailsCheck.js b/components/account/personaldetailsCheck.js index e1150161..c4df3bff 100644 --- a/components/account/personaldetailsCheck.js +++ b/components/account/personaldetailsCheck.js @@ -17,6 +17,7 @@ const BuildCheckPersonalDetails = (props) => { handleSubmit, value, setPersonalDetailsComplete, + setAccountUpdatedComplete, } = props; let { t, lang } = useTranslation(); @@ -30,11 +31,10 @@ const BuildCheckPersonalDetails = (props) => {
First name
- {/* {console.log( - props.props.form["personalDetailsForm"].values[ - "firstname" - ] - )} */} + { + props.props.props.form.personalDetailsForm.values + .firstname + }
{
Last name
- {/* {console.log( - props.props.form["personalDetailsForm"].values[ - "firstname" - ] - )} */} + { + props.props.props.form.personalDetailsForm.values + .lastname + }
{
Email address
- {/* {console.log( - props.props.form["personalDetailsForm"].values[ - "firstname" - ] - )} */} + { + props.props.props.form.personalDetailsForm.values + .email + }
{
Telephone
- {/* {console.log( - props.props.form["personalDetailsForm"].values[ - "firstname" - ] - )} */} + { + props.props.props.form.personalDetailsForm.values + .telephone + }
{
Company/Group
- {/* {console.log( - props.props.form["personalDetailsForm"].values[ - "firstname" - ] - )} */} + { + props.props.props.form.personalDetailsForm.values + .companygroup + }
{
Address Line 1
- {/* {console.log( - props.props.form["personalDetailsForm"].values[ - "firstname" - ] - )} */} + { + props.props.props.form.personalDetailsForm.values + .addressline1 + }
{
Address line 2
- {/* {console.log( - props.props.form["personalDetailsForm"].values[ - "firstname" - ] - )} */} + { + props.props.props.form.personalDetailsForm.values + .addressline2 + }
{
Town/City
- {/* {console.log( - props.props.form["personalDetailsForm"].values[ - "firstname" - ] - )} */} + { + props.props.props.form.personalDetailsForm.values + .towncity + }
{
County
- {/* {console.log( - props.props.form["personalDetailsForm"].values[ - "firstname" - ] - )} */} + { + props.props.props.form.personalDetailsForm.values + .county + }
{
Postcode
- {/* {console.log( - props.props.form["personalDetailsForm"].values[ - "firstname" - ] - )} */} + { + props.props.props.form.personalDetailsForm.values + .postcode + }
{
+
+ +
); }; @@ -303,8 +306,6 @@ const mapDispatchToProps = (dispatch) => { }; }; -const selector = formValueSelector("personalDetailsForm"); // <-- same as form name - export default connect( mapStateToProps, mapDispatchToProps diff --git a/components/account/personaldetailsComplete.js b/components/account/personaldetailsComplete.js new file mode 100644 index 00000000..757444e1 --- /dev/null +++ b/components/account/personaldetailsComplete.js @@ -0,0 +1,74 @@ +import _ from "lodash"; +import Link from "next/link"; +import React, { useState } from "react"; +import { useRouter } from "next/router"; +import useTranslation from "next-translate/useTranslation"; +import { + Field, + reduxForm, + formValueSelector, + getFormSubmitErrors, +} from "redux-form"; +import { + useDispatch, + useSelector, + shallowEqual, + connect, + setRegisterFormComplete, + setAccountCreatedComplete, +} from "react-redux"; + +const PersonalDetailsComplete = (props) => { + const { + handleSubmit, + value, + setRegisterFormComplete, + setAccountCreatedComplete, + } = props; + let { t, lang } = useTranslation(); + + const router = useRouter(); + const { locale } = router; + + return ( + <> +

Your details have been updated

+ +

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi a + metus non quam mollis egestas. Integer ac leo cursus, laoreet + nulla sed, tempus tellus. Mauris condimentum erat arcu. +

+ +

+ + Return to My Portal + +

+ + ); +}; + +const mapStateToProps = (state) => { + return { + search: state.search, + searchResultsObj: state.searchResultsObj, + formData: state.formData, + appealType: state.appealType, + accountDetails: state.accountDetails, + //form: state.form, + }; +}; + +const mapDispatchToProps = (dispatch) => { + return { + setCurrentSection: (currentSection) => { + dispatch(setCurrentSection(currentSection)); + }, + }; +}; + +export default connect( + mapStateToProps, + mapDispatchToProps +)(PersonalDetailsComplete); diff --git a/components/account/registerCheck.js b/components/account/registerCheck.js new file mode 100644 index 00000000..6e2c4f78 --- /dev/null +++ b/components/account/registerCheck.js @@ -0,0 +1,310 @@ +import _ from "lodash"; +import React, { useState } from "react"; +import { useRouter } from "next/router"; +import useTranslation from "next-translate/useTranslation"; +import { + Field, + reduxForm, + formValueSelector, + getFormSubmitErrors, +} from "redux-form"; +import { useDispatch, useSelector, shallowEqual, connect } from "react-redux"; + +const RegisterFormCheck = (props) => { + const { + footerLinks, + pages, + handleSubmit, + value, + setRegisterFormComplete, + setAccountCreatedComplete, + } = props; + let { t, lang } = useTranslation(); + + const router = useRouter(); + const { locale } = router; + + return ( + <> +

Check that the details you entered are correct.

+

About you

+
+
+
First name
+
+ { + props.props.props.form.accountRegisterForm.values + .firstname + } +
+
+ { + setRegisterFormComplete(false); + }} + > + Change + + first name + + +
+
+
+
Last name
+
+ { + props.props.props.form.accountRegisterForm.values + .lastname + } +
+
+ { + setRegisterFormComplete(false); + }} + > + Change + + {" "} + last name + + +
+
+
+
Email address
+
+ { + props.props.props.form.accountRegisterForm.values + .email + } +
+
+ { + setRegisterFormComplete(false); + }} + > + Change + + {" "} + email address + + +
+
+
+
Telephone
+
+ { + props.props.props.form.accountRegisterForm.values + .telephone + } +
+
+ { + setRegisterFormComplete(false); + }} + > + Change + + telephone + + +
+
+
+
Company/Group
+
+ { + props.props.props.form.accountRegisterForm.values + .companygroup + } +
+
+ { + setRegisterFormComplete(false); + }} + > + Change + + {" "} + company/group + + +
+
+
+
+

Your address

+ +
+
Address Line 1
+
+ { + props.props.props.form.accountRegisterForm.values + .addressline1 + } +
+
+ { + setRegisterFormComplete(false); + }} + > + Change + + {" "} + address line 1 + + +
+
+
+
Address line 2
+
+ { + props.props.props.form.accountRegisterForm.values + .addressline2 + } +
+
+ { + setRegisterFormComplete(false); + }} + > + Change + + {" "} + address line 2 + + +
+
+
+
Town/City
+
+ { + props.props.props.form.accountRegisterForm.values + .towncity + } +
+
+ { + setRegisterFormComplete(false); + }} + > + Change + + {" "} + town/city + + +
+
+
+
County
+
+ { + props.props.props.form.accountRegisterForm.values + .county + } +
+
+ { + setRegisterFormComplete(false); + }} + > + Change + + {" "} + county + + +
+
+
+
Postcode
+
+ { + props.props.props.form.accountRegisterForm.values + .postcode + } +
+
+ { + setRegisterFormComplete(false); + }} + > + Change + + {" "} + postcode + + +
+
+
+
+ +
+ + ); +}; + +const mapStateToProps = (state) => { + return { + search: state.search, + searchResultsObj: state.searchResultsObj, + formData: state.formData, + appealType: state.appealType, + accountDetails: state.accountDetails, + //form: state.form, + }; +}; + +const mapDispatchToProps = (dispatch) => { + return { + setCurrentSection: (currentSection) => { + dispatch(setCurrentSection(currentSection)); + }, + }; +}; + +export default connect(mapStateToProps, mapDispatchToProps)(RegisterFormCheck); diff --git a/components/account/registerComplete.js b/components/account/registerComplete.js new file mode 100644 index 00000000..8c117be8 --- /dev/null +++ b/components/account/registerComplete.js @@ -0,0 +1,82 @@ +import _ from "lodash"; +import Link from "next/link"; +import React, { useState } from "react"; +import { useRouter } from "next/router"; +import useTranslation from "next-translate/useTranslation"; +import { + Field, + reduxForm, + formValueSelector, + getFormSubmitErrors, +} from "redux-form"; +import { + useDispatch, + useSelector, + shallowEqual, + connect, + setRegisterFormComplete, + setAccountCreatedComplete, +} from "react-redux"; + +const RegisterComplete = (props) => { + const { + footerLinks, + pages, + handleSubmit, + value, + setRegisterFormComplete, + setAccountCreatedComplete, + } = props; + let { t, lang } = useTranslation(); + + const router = useRouter(); + const { locale } = router; + + return ( + <> +

We have sent you a confirmation email.

+ +

What happens next

+ +

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi a + metus non quam mollis egestas. Integer ac leo cursus, laoreet + nulla sed, tempus tellus. Mauris condimentum erat arcu. +

+

+ Sed imperdiet dignissim ipsum. Orci varius natoque penatibus et + magnis dis parturient montes, nascetur ridiculus mus. In id leo + in turpis aliquam venenatis ut non erat. Ut est arcu, luctus sit + amet pretium sed, iaculis non purus. Etiam dictum tortor commodo + luctus rhoncus. +

+ +

+ + Login to My Portal + +

+ + ); +}; + +const mapStateToProps = (state) => { + return { + search: state.search, + searchResultsObj: state.searchResultsObj, + formData: state.formData, + appealType: state.appealType, + accountDetails: state.accountDetails, + //form: state.form, + }; +}; + +const mapDispatchToProps = (dispatch) => { + return { + setCurrentSection: (currentSection) => { + dispatch(setCurrentSection(currentSection)); + }, + }; +}; + +export default connect(mapStateToProps, mapDispatchToProps)(RegisterComplete); diff --git a/components/account/registerform.js b/components/account/registerform.js index b751f88a..9fcf8128 100644 --- a/components/account/registerform.js +++ b/components/account/registerform.js @@ -9,17 +9,9 @@ import { getFormSubmitErrors, } from "redux-form"; import { useDispatch, useSelector, shallowEqual, connect } from "react-redux"; -import { - Textfield, - DateField, - DateFieldPicker, - YesNofield, - PickList, - MultiLinefield, - NumericField, - ReadOnlyfield, - DecimalField, -} from "../elements"; + +import RegisterFormCheck from "./registerCheck"; +import RegisterComplete from "./registerComplete"; const RenderTextfield = ({ id, @@ -69,7 +61,12 @@ const RenderTextfield = ({ }; const RegisterForm = (props) => { - const { footerLinks, pages, handleSubmit, value } = props; + const { + handleSubmit, + value, + setRegisterFormComplete, + setAccountCreatedComplete, + } = props; let { t, lang } = useTranslation(); const router = useRouter(); @@ -77,10 +74,6 @@ const RegisterForm = (props) => { let errorsobj = {}; - const onHandleSubmit = (values) => { - console.log(values); - }; - const required = (value) => (value ? undefined : "Is required"); const email = (value) => value && !/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(value) @@ -96,139 +89,148 @@ const RegisterForm = (props) => { const [hasErrors, setHasErrors] = useState(""); + const onHandleSubmit = (values) => { + setRegisterFormComplete(true); + }; + return ( <> - {/* {hasErrors == true ? ( - + {props.accountCreatedComplete != true ? ( + props.registerFormComplete == false ? ( +
+
+ +

+ About you +

+
+ + + + + + +
+
+ +

+ What is your address? +

+
+ + + + + + +
+ +
+ +
+
+ ) : ( + + ) ) : ( - "" - )} */} -
-
- -

About you

-
- - - - - - -
-
- -

- What is your address? -

-
- - - - - - -
- -
- -
-
+ + )} ); }; diff --git a/components/breadcrumbs.js b/components/breadcrumbs.js index 15455839..ceaf71aa 100644 --- a/components/breadcrumbs.js +++ b/components/breadcrumbs.js @@ -182,6 +182,15 @@ const Breadcrumbs = (props) => { ) : ( "" )} + {router.pathname == "/account/register" ? ( + <> +
  • + Register your account +
  • + + ) : ( + "" + )} {router.pathname == "/account/changepassword" ? ( <>
  • diff --git a/components/header.js b/components/header.js index a355acc5..fa6b92d2 100644 --- a/components/header.js +++ b/components/header.js @@ -1,12 +1,14 @@ import Link from "next/link"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; - -export default function Header({ courseName }) { +import { useDispatch, useSelector, shallowEqual, connect } from "react-redux"; +import { setLogout } from "../store/accountDetails/action"; +const Header = (props) => { let { t, lang } = useTranslation(); const router = useRouter(); const { locale } = router; + const { setLogout } = props; return (
    ); -} +}; +const mapDispatchToProps = (dispatch) => { + return { + setLogout: () => { + dispatch(setLogout()); + }, + }; +}; + +export default connect(null, mapDispatchToProps)(Header); diff --git a/pages/404.js b/pages/404.js new file mode 100644 index 00000000..8ba64663 --- /dev/null +++ b/pages/404.js @@ -0,0 +1,13 @@ +// 404.js +import Link from "next/link"; + +export default function FourOhFour() { + return ( + <> +

    404 - Page Not Found

    + + Go back home + + + ); +} diff --git a/pages/account/changepassword.js b/pages/account/changepassword.js index 2261c885..3d2c44c5 100644 --- a/pages/account/changepassword.js +++ b/pages/account/changepassword.js @@ -37,6 +37,7 @@ const Home = (props) => { const { appealtypes } = router.query; const { appealType, LPAData } = props; + const [passwordUpdated, setPasswordUpdated] = useState(false); return (
    @@ -61,8 +62,20 @@ const Home = (props) => { >
    -

    Change password

    - + {passwordUpdated == true ? ( +

    + Your password has been changed +

    + ) : ( +

    Change password

    + )} +
    diff --git a/pages/account/personaldetails.js b/pages/account/personaldetails.js index 837aa2b6..95941101 100644 --- a/pages/account/personaldetails.js +++ b/pages/account/personaldetails.js @@ -17,10 +17,8 @@ import jsonpath from "jsonpath"; import { reduxForm, formValueSelector } from "redux-form"; import PersonalDetails from "../../components/account/personaldetails"; -import xpath from "xpath"; import { setAccountDetails } from "../../store/accountDetails/action"; import { getPersonalAccount } from "../../actions"; -import { setLPA } from "../../store/lpa/action"; const Home = (props) => { const { footerLinks, formData } = props; @@ -30,7 +28,9 @@ const Home = (props) => { const { locale } = router; const { appealtypes } = router.query; - const { appealType, LPAData } = props; + const [personalDetailsComplete, setPersonalDetailsComplete] = + useState(false); + const [accountUpdatedComplete, setAccountUpdatedComplete] = useState(false); return (
    @@ -56,7 +56,21 @@ const Home = (props) => {

    Your account

    - +
    @@ -70,14 +84,14 @@ const Home = (props) => { ); }; -export const getServerSideProps = wrapper.getServerSideProps( - (store) => - async ({ query, req, res }) => { - const accountDetails = await getPersonalAccount(); - console.log("perosnal: ", accountDetails); - store.dispatch(setAccountDetails(accountDetails)); - } -); +// export const getServerSideProps = wrapper.getServerSideProps( +// (store) => +// async ({ query, req, res }) => { +// const accountDetails = await getPersonalAccount(); +// console.log("perosnal: ", accountDetails); +// store.dispatch(setAccountDetails(accountDetails)); +// } +// ); const mapStateToProps = (state) => { return { diff --git a/pages/account/register.js b/pages/account/register.js index 5c80398e..3117818f 100644 --- a/pages/account/register.js +++ b/pages/account/register.js @@ -17,26 +17,17 @@ import jsonpath from "jsonpath"; import { reduxForm, formValueSelector } from "redux-form"; import RegisterForm from "../../components/account/registerform"; -import xpath from "xpath"; -import { - setAppealType, - setAppealTypeTitle, - setAppealTypeID, - setAppealLPA, - getAppealTypeObj, -} from "../../store/appealType/action"; -import { getAppealsTypes, getLPA } from "../../actions"; -import { setLPA } from "../../store/lpa/action"; const Home = (props) => { - const { footerLinks, pages, formData } = props; + const { footerLinks, formData } = props; let { t, lang } = useTranslation(); const router = useRouter(); const { locale } = router; const { appealtypes } = router.query; - const { appealType, LPAData } = props; + const [registerFormComplete, setRegisterFormComplete] = useState(false); + const [accountCreatedComplete, setAccountCreatedComplete] = useState(false); return (
    @@ -61,59 +52,87 @@ const Home = (props) => { >
    -

    Create a new account

    - + {registerFormComplete != true || + accountCreatedComplete != true ? ( +

    Create a new account

    + ) : ( +

    + Your account has been created +

    + )} +
    + {registerFormComplete != true || + accountCreatedComplete != true ? ( +
    +

    + Help +

    -
    -

    - Help -

    +

    + Companies or submissions by more + than one individual (groups) +

    -

    - Companies or submissions by more - than one individual (groups) -

    +

    + If you are submitting an appeal + or representation from a company + e.g. "Acme Inc" or a + group of people e.g. + "Residents of 1-10 High + street", you should enter + the name of the company or group + in the Company/Group field. You + will be deemed as acting as + their representative. +

    -

    - If you are submitting an appeal or - representation from a company e.g. - "Acme Inc" or a group of - people e.g. "Residents of 1-10 - High street", you should enter - the name of the company or group in - the Company/Group field. You will be - deemed as acting as their - representative. -

    +

    + Enforcement appeals by + married/civil partnership + couples +

    -

    - Enforcement appeals by married/civil - partnership couples -

    +

    + You should not enter a group + name. You need only enter your + partner's name on the + appeal form itself as an + additional appellant. +

    -

    - You should not enter a group name. - You need only enter your - partner's name on the appeal - form itself as an additional - appellant. -

    +

    + Other appeals by married/civil + partnership couples +

    -

    - Other appeals by married/civil - partnership couples -

    - -

    - For any other type of appeal, for - example a planning appeal, you - should enter a group name when - creating your account e.g. "Mr - and Mrs Smith", if that is the - name on the application. -

    -
    +

    + For any other type of appeal, + for example a planning appeal, + you should enter a group name + when creating your account e.g. + "Mr and Mrs Smith", if + that is the name on the + application. +

    +
    + ) : ( + "" + )}
    @@ -126,17 +145,17 @@ const Home = (props) => { ); }; -export const getServerSideProps = wrapper.getServerSideProps( - (store) => - async ({ query, req, res }) => { - const appealTypeData = await getAppealsTypes(); - const lpaData = await getLPA(); - console.log("appeal types", appealTypeData); - console.log("lpa typeswwwww", lpaData); - store.dispatch(setAppealType(appealTypeData)); - store.dispatch(setLPA(lpaData)); - } -); +// export const getServerSideProps = wrapper.getServerSideProps( +// (store) => +// async ({ query, req, res }) => { +// const appealTypeData = await getAppealsTypes(); +// const lpaData = await getLPA(); +// console.log("appeal types", appealTypeData); +// console.log("lpa typeswwwww", lpaData); +// store.dispatch(setAppealType(appealTypeData)); +// store.dispatch(setLPA(lpaData)); +// } +// ); const mapStateToProps = (state) => { return { @@ -146,6 +165,7 @@ const mapStateToProps = (state) => { appealType: state.appealType, LPAData: state.LPAData, form: state.form, + accountDetails: state.accountDetails, }; }; diff --git a/pages/logout.js b/pages/logout.js new file mode 100644 index 00000000..21fd1d78 --- /dev/null +++ b/pages/logout.js @@ -0,0 +1,50 @@ +import _ from "lodash"; +import Link from "next/link"; +import Head from "next/head"; +import Header from "../components/header"; +import Banner from "../components/banner"; +import CookieBanner from "../components/cookieBanner"; + +import Footer from "../components/footer"; +import { useSelector, shallowEqual, connect } from "react-redux"; +import { useRouter } from "next/router"; +import useTranslation from "next-translate/useTranslation"; +import { setLogout } from "../store/accountDetails/action"; + +const LogOut = (props) => { + const { footerLinks, pages, setLogout } = props; + let { t, lang } = useTranslation(); + + const router = useRouter(); + const { locale } = router; + setLogout(); + return ( +
    + + {t("common:service-name")} + +
    + +
    +
    + +

    You have been logged out

    +
    + Return to Planning Casework portal +
    +
    +
    +
    + ); +}; + +const mapDispatchToProps = (dispatch) => { + return { + setLogout: () => { + dispatch(setLogout()); + }, + }; +}; + +export default connect(null, mapDispatchToProps)(LogOut); diff --git a/store/accountDetails/action.js b/store/accountDetails/action.js index f106d058..efc3a7f2 100644 --- a/store/accountDetails/action.js +++ b/store/accountDetails/action.js @@ -15,3 +15,9 @@ export const setAccountDetails = (accountDetails) => (dispatch) => { accountDetails: accountDetails, }); }; + +export const setLogout = () => (dispatch) => { + return dispatch({ + type: "USER_LOGOUT", + }); +}; diff --git a/store/store.js b/store/store.js index 83769736..89fcc1b5 100644 --- a/store/store.js +++ b/store/store.js @@ -9,9 +9,10 @@ import LPAData from "./lpa/reducer"; import accountDetails from "./accountDetails/reducer"; import { reducer as formReducer } from "redux-form"; import autoMergeLevel2 from "redux-persist/lib/stateReconciler/autoMergeLevel2"; +import storage from "redux-persist/lib/storage"; //COMBINING ALL REDUCERS -const combinedReducer = combineReducers({ +const appReducer = combineReducers({ search, searchResultsObj, formData, @@ -21,6 +22,16 @@ const combinedReducer = combineReducers({ form: formReducer, }); +const combinedReducer = (state, action) => { + if (action.type === "USER_LOGOUT") { + // for all keys defined in your persistConfig(s) + storage.removeItem("persist:acp"); + // storage.removeItem('persist:otherKey') + return appReducer(undefined, action); + } + return appReducer(state, action); +}; + const reducer = (state = {}, action) => { switch (action.type) { case HYDRATE: @@ -77,7 +88,7 @@ const makeStore = ({ isServer }) => { const storage = require("redux-persist/lib/storage").default; const persistConfig = { - key: "nextjs", + key: "acp", whitelist: [ "search", "searchResults", @@ -87,7 +98,7 @@ const makeStore = ({ isServer }) => { "accountDetails", "form", ], - storage, + storage: storage, stateReconciler: autoMergeLevel2, // if needed, use a safer storage };