Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.js
- class App extends Component {
- if(this.props.auth.context) {
- const lastName = this.props.auth.context.lastName;
- const addresses = this.props.auth.context.addresses;
- const phone = this.props.auth.context.phone;
- hasProfile = lastName && addresses.length > 0 && phone.length > 0;
- }
- render() {
- return (
- <App>
- <Header />
- <Routes
- hasProfile={hasProfile}
- authenticated={this.props.auth && this.props.auth.authenticated}
- />
- <Footer />
- </App>
- )
- }
- }
- ---------------------------------------------------------------------------------------------------------------
- routes.js
- <ConnectedRouter>
- <Switch>
- <Route exact path="/user-profile" render={(props) => (
- !hasProfile && authenticated ? (<BuildProfile/>) :
- (<Redirect to={{ pathname: '/auth/createAccount'}}/>)
- <Route exact path="/user-profile/home" render={(props) => (
- hasProfile && authenticated ? (<Home/>) :
- (<Redirect to={{pathname: '/auth/createAccount'}}/>)
- </Switch>
- </ConnectedRouter>
- ---------------------------------------------------------------------------------------------------------------
- BuildProfile.js
- User adds last name, addresses and phone. Then they are redirected to profile Home.
Add Comment
Please, Sign In to add comment