reps trigger for logged out & upload storage acc

This commit is contained in:
2023-01-05 14:26:08 +00:00
parent 98aefdd867
commit ee4d00a500
16 changed files with 251 additions and 465 deletions
+44 -3
View File
@@ -1,7 +1,9 @@
import useTranslation from "next-translate/useTranslation";
import Head from "next/head";
import { useEffect } from "react";
import { useRouter } from "next/router";
import { connect } from "react-redux";
import { connect, useDispatch } from "react-redux";
import Breadcrumbs from "../../components/breadcrumbs";
import CookieBanner from "../../components/cookieBanner";
import Footer from "../../components/footer";
@@ -9,7 +11,17 @@ import Header from "../../components/header";
import Case from "../../components/representation";
import { wrapper } from "../../store/store";
import { getSession, useSession } from "next-auth/react";
import { getPersonalAccount } from "../../actions";
import {
consoleLogger,
getPersonalAccount,
getPortalLogin,
} from "../../actions";
import {
setRepresentationCapacity,
setRepresentationSubmit,
setSubmitBack,
setRepresentationSubmitConfirmation,
} from "../../store/currentView/action";
import {
setAccountDetails,
setContainerID,
@@ -24,6 +36,27 @@ const Home = (props) => {
const { locale } = router;
const { appealtypes } = router.query;
const dispatch = useDispatch();
useEffect(async () => {
const thisSession = await getSession();
if (thisSession) {
let [loggedInUser] = await Promise.all([
await getPortalLogin(thisSession.user.email),
]);
dispatch(
setAccountDetails(
await getPersonalAccount(loggedInUser.value[0].contactid)
)
);
dispatch(setContainerID(thisSession.user.id));
//dispatch(setRepresentationSubmit(true));
}
}, [dispatch]);
return (
<div>
<Head>
@@ -148,6 +181,14 @@ const Home = (props) => {
// }
// );
const mapDispatchToProps = (dispatch) => {
return {
setAccountDetails: (loggedInUser) => {
dispatch(setAccountDetails(loggedInUser));
},
};
};
const mapStateToProps = (state) => {
//console.log(state);
@@ -166,4 +207,4 @@ const mapStateToProps = (state) => {
};
};
export default connect(mapStateToProps)(Home);
export default connect(mapStateToProps, mapDispatchToProps)(Home);