reps trigger for logged out & upload storage acc
This commit is contained in:
+12
-10
@@ -162,23 +162,25 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
let loggedInUserCookie = cookies.pinsUser;
|
||||
|
||||
let thisSession = await getSession(ctx);
|
||||
let loggedInUser = {};
|
||||
|
||||
let [loggedInUser] = await Promise.all([
|
||||
await getPortalLogin(thisSession.user.email),
|
||||
]);
|
||||
|
||||
loggedInUser = loggedInUser.value[0].contactid;
|
||||
console.log("nextAuth Session:", thisSession);
|
||||
|
||||
if (_.has(thisSession, "user") == false) {
|
||||
if (!thisSession) {
|
||||
console.log("not has sesssion.......");
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/error",
|
||||
destination: "/auth/signin",
|
||||
permanent: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
} else {
|
||||
console.log(" has sesssion.......");
|
||||
[loggedInUser] = await Promise.all([
|
||||
await getPortalLogin(thisSession.user.email),
|
||||
]);
|
||||
|
||||
loggedInUser = loggedInUser.value[0].contactid;
|
||||
console.log("nextAuth Session:", thisSession);
|
||||
}
|
||||
//Create Storage container for logged in user
|
||||
await createContainer(thisSession.user.id);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -29,6 +29,8 @@ import {
|
||||
setWatchedCases,
|
||||
setWatchedCasesDetails,
|
||||
} from "../../store/watchedCases/action";
|
||||
import { setShowReps } from "../../store/currentView/action";
|
||||
|
||||
import TimeOut from "../../components/timeout";
|
||||
import { getSession, useSession } from "next-auth/react";
|
||||
import {
|
||||
@@ -87,6 +89,11 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
await getPortalLogin(thisSession.user.email),
|
||||
]);
|
||||
|
||||
const showReps = process.env.SHOWREPRESENTATIONS || false;
|
||||
|
||||
console.log("env var ", process.env.SHOWREPRESENTATIONS);
|
||||
store.dispatch(setShowReps(showReps));
|
||||
|
||||
searchResultsObj =
|
||||
searchResultsObj.status == 502
|
||||
? {
|
||||
|
||||
Reference in New Issue
Block a user