sign up check for tenants
This commit is contained in:
parent
80e9f5655b
commit
55074f391d
4 changed files with 16 additions and 26 deletions
|
|
@ -22,6 +22,7 @@ import FunnelIssueDetails from 'Components/Funnels/FunnelIssueDetails';
|
|||
import APIClient from './api_client';
|
||||
import * as routes from './routes';
|
||||
import Signup from './components/Signup/Signup';
|
||||
import { fetchTenants } from 'Duck/user';
|
||||
|
||||
const BugFinder = withSiteIdUpdater(BugFinderPure);
|
||||
const Dashboard = withSiteIdUpdater(DashboardPure);
|
||||
|
|
@ -54,20 +55,22 @@ const ONBOARDING_PATH = routes.onboarding();
|
|||
const jwt = state.get('jwt');
|
||||
const changePassword = state.getIn([ 'user', 'account', 'changePassword' ]);
|
||||
const userInfoLoading = state.getIn([ 'user', 'fetchUserInfoRequest', 'loading' ]);
|
||||
const fetchingTenants = state.get('user', 'fetchTenantsRequest', 'loading');
|
||||
return {
|
||||
jwt,
|
||||
siteId,
|
||||
changePassword,
|
||||
sites: state.getIn([ 'user', 'client', 'sites' ]),
|
||||
isLoggedIn: jwt !== null && !changePassword,
|
||||
loading: siteId === null || userInfoLoading,
|
||||
loading: siteId === null || userInfoLoading || fetchingTenants,
|
||||
email: state.getIn([ 'user', 'account', 'email' ]),
|
||||
account: state.getIn([ 'user', 'account' ]),
|
||||
organisation: state.getIn([ 'user', 'client', 'name' ]),
|
||||
tenantId: state.getIn([ 'user', 'client', 'tenantId' ]),
|
||||
tenants: state.getIn(['user', 'tenants']),
|
||||
};
|
||||
}, {
|
||||
fetchUserInfo,
|
||||
fetchUserInfo, fetchTenants
|
||||
})
|
||||
class Router extends React.Component {
|
||||
constructor(props) {
|
||||
|
|
@ -76,6 +79,7 @@ class Router extends React.Component {
|
|||
Promise.all([props.fetchUserInfo()])
|
||||
.then(() => this.onLoginLogout());
|
||||
}
|
||||
props.fetchTenants();
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
|
|
@ -89,7 +93,7 @@ class Router extends React.Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { isLoggedIn, jwt, siteId, sites, loading, changePassword, location } = this.props;
|
||||
const { isLoggedIn, jwt, siteId, sites, loading, changePassword, location, tenants } = this.props;
|
||||
const siteIdList = sites.map(({ id }) => id).toJS();
|
||||
const hideHeader = location.pathname && location.pathname.includes('/session/');
|
||||
|
||||
|
|
@ -138,7 +142,7 @@ class Router extends React.Component {
|
|||
<Switch>
|
||||
<Route exact strict path={ FORGOT_PASSWORD } component={ ForgotPassword } />
|
||||
<Route exact strict path={ LOGIN_PATH } component={ changePassword ? UpdatePassword : Login } />
|
||||
<Route exact strict path={ SIGNUP_PATH } component={ Signup } />
|
||||
{ tenants.length === 0 && <Route exact strict path={ SIGNUP_PATH } component={ Signup } /> }
|
||||
<Redirect to={ LOGIN_PATH } />
|
||||
</Switch>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ const Header = (props) => {
|
|||
to={ withSiteId(DASHBOARD_PATH, siteId) }
|
||||
className={ styles.nav }
|
||||
activeClassName={ styles.active }
|
||||
>
|
||||
>
|
||||
<span>{ 'Metrics' }</span>
|
||||
</NavLink>
|
||||
<div className={ styles.right }>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
import React, { useState } from 'react'
|
||||
import { Icon, Loader, Button, Link, Dropdown, CircularLoader } from 'UI'
|
||||
import { forgotPassword, login } from 'App/routes'
|
||||
import React from 'react'
|
||||
import { Icon, Button, Link, Dropdown, CircularLoader } from 'UI'
|
||||
import { login } from 'App/routes'
|
||||
import ReCAPTCHA from 'react-google-recaptcha'
|
||||
import stl from './signup.css'
|
||||
import cn from 'classnames'
|
||||
import { signup, fetchTenants } from 'Duck/user';
|
||||
import { signup } from 'Duck/user';
|
||||
import { connect } from 'react-redux'
|
||||
|
||||
const FORGOT_PASSWORD = forgotPassword()
|
||||
const LOGIN_ROUTE = login()
|
||||
const recaptchaRef = React.createRef()
|
||||
|
||||
|
|
@ -17,7 +15,7 @@ const recaptchaRef = React.createRef()
|
|||
errors: state.getIn([ 'user', 'signupRequest', 'errors' ]),
|
||||
loading: state.getIn([ 'user', 'signupRequest', 'loading' ]),
|
||||
}),
|
||||
{ signup, fetchTenants },
|
||||
{ signup },
|
||||
)
|
||||
export default class SignupForm extends React.Component {
|
||||
|
||||
|
|
@ -30,10 +28,6 @@ export default class SignupForm extends React.Component {
|
|||
organizationName: '',
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.props.fetchTenants();
|
||||
}
|
||||
|
||||
handleSubmit = (token) => {
|
||||
const { tenantId, fullname, password, email, projectName, organizationName, auth } = this.state;
|
||||
this.props.signup({ tenantId, fullname, password, email, projectName, organizationName, auth, 'g-recaptcha-response': token })
|
||||
|
|
@ -165,17 +159,8 @@ export default class SignupForm extends React.Component {
|
|||
'Signup'
|
||||
}
|
||||
</Button>
|
||||
|
||||
{/* <div className={ cn(stl.links, 'text-lg') }>
|
||||
<Link to={ LOGIN_ROUTE }>{'Back to Login'}</Link>
|
||||
</div> */}
|
||||
</div>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// export default connect(state => ({
|
||||
// errors: state.getIn([ 'user', 'signupRequest', 'errors' ]),
|
||||
// loading: state.getIn([ 'user', 'signupRequest', 'loading' ]),
|
||||
// }), { signup })(SignupForm)
|
||||
}
|
||||
|
|
@ -91,6 +91,7 @@ export default withRequestState({
|
|||
putClientRequest: PUT_CLIENT,
|
||||
updateAccountRequest: UPDATE_ACCOUNT,
|
||||
updateAppearance: UPDATE_APPEARANCE,
|
||||
fetchTenantsRequest: FETCH_TENANTS,
|
||||
}, reducer);
|
||||
|
||||
export const login = params => dispatch => dispatch({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue