Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#326: redirect user to welcome and show disclaimer in every page #367

Open
wants to merge 2 commits into
base: feature/polling-service-producer
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions src/bootstrap/App.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { Component } from "react";

import Init from './Init'
import Init from "./Init";

import { Provider } from 'react-redux'
import { Provider } from "react-redux";
import AppProvider from "./AppProvider"; // App Context

import ErrorBoundary from "./ErrorBoundary"; // Errors
Expand All @@ -17,33 +17,31 @@ import Spinner from "../components/common/Spinner";
import UnderAuth from "./UnderAuth";
import Initializer from "./Initializer"; // Initializer
import { log, connector, connection } from "../utils/helpers";
import Disclaimer, { ModalDiscliamer } from "JurCommon/Disclaimer";

log('App init', process.env);
log("App init", process.env);

class App extends Component {
constructor(props) {
super(props);
this.connectorValue = connector();

}

componentDidMount() {
if (this.connectorValue === 'connex') {
if (this.connectorValue === "connex") {
const { store } = this.props;
global.store=store;
global.store = store;
}
}

render() {
const { store, history, testElement } = this.props;

// log('connnnnnnnnnection---g---', typeof connection)



log('App - connector',this.connectorValue)
log("App - connector", this.connectorValue);

if (this.connectorValue === 'web3') {
if (this.connectorValue === "web3") {
return (
<AppProvider store={store}>
<ErrorBoundary>
Expand All @@ -58,7 +56,7 @@ class App extends Component {
</ErrorBoundary>
</AppProvider>
);
} else if (this.connectorValue === 'connex') {
} else if (this.connectorValue === "connex") {
return (
<AppProvider store={store}>
<ErrorBoundary>
Expand All @@ -67,8 +65,9 @@ class App extends Component {
<UnderAuth>
<Provider store={store}>
<Initializer history={history} testElement={testElement} />
<Disclaimer />
</Provider>
</UnderAuth>
</UnderAuth>
</>
</ErrorBoundary>
</AppProvider>
Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/Initializer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-unused-vars */
import React, { PureComponent } from "react";
import { Route, Switch, Router } from "react-router"; // react-router v4

import { ConnectedRouter } from "connected-react-router";
import PropTypes from "prop-types";

// Routes
Expand Down Expand Up @@ -29,7 +29,7 @@ class Initializer extends PureComponent {
render() {
const { history } = this.props;
return (
<Router history={history}>
<ConnectedRouter history={history}>
<>
<Switch>
{Routes.map((params, key) => (
Expand All @@ -39,7 +39,7 @@ class Initializer extends PureComponent {

{this.renderTestReport()}
</>
</Router>
</ConnectedRouter>
);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/sections/Status/Advocates.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import AdvocatesHeader from "../../app-specific/Advocate/AdvocatesHeader";
import AdvocatesIndex from "../../app-specific/Advocate/AdvocatesIndex";
import AdvocatesFooterBox from "../../app-specific/Advocate/AdvocatesFooterBox";
import { ADVOCATE_RESET_SORTS } from "../../../reducers/types";
import Disclaimer from "JurCommon/Disclaimer";

const Advocates = ({ resetSorts }) => {
useEffect(() => resetSorts, []);
Expand All @@ -33,6 +34,7 @@ const Advocates = ({ resetSorts }) => {
<AdvocatesHeader />
<AdvocatesIndex />
<AdvocatesFooterBox />
<Disclaimer />
</div>
</Main>
</PageLayout>
Expand Down
3 changes: 3 additions & 0 deletions src/sagas/User.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { put, call, select, takeEvery, takeLatest } from "redux-saga/effects";
import { push } from "connected-react-router";
import { setLoading } from "./App";

import { dateReducer } from "../utils/helpers"; // helpers
Expand Down Expand Up @@ -79,8 +80,10 @@ export function* checkUserExist(action) {
log("checkUserExist - error.response", error.response);
if (error.response.status === 404) {
log("checkUserExist - error.response.status", error.response.status);
put(push("/"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we yield on this put call?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redirection is made on saga so if the user tries to access the page directly from url then it will be redirected to homepage and if he has not seen welcome wizard will be displayed otherwise the disclaimer will be shown but not redirected to welcome wizard

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also expect that to happen, but it didn't happen when I tried with a new user to visit http://localhost:3000/profile/my-advocacy

The user wasn't redirected. I think a better solution is to rely on the cookie that @marcomarasco talked about.

// create a new user if missing
if (action.type === FETCH_USER) {
log("This is fetch_user action type");
yield put({ type: SET_LOADING, payload: false }); // only dismiss loading
} else {
yield put({ type: NEW_USER }); // create a new user
Expand Down