Guest User

Untitled

a guest
Dec 11th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. app.js
  2.  
  3. class App extends Component {
  4. if(this.props.auth.context) {
  5. const lastName = this.props.auth.context.lastName;
  6. const addresses = this.props.auth.context.addresses;
  7. const phone = this.props.auth.context.phone;
  8. hasProfile = lastName && addresses.length > 0 && phone.length > 0;
  9. }
  10. render() {
  11. return (
  12. <App>
  13. <Header />
  14. <Routes
  15. hasProfile={hasProfile}
  16. authenticated={this.props.auth && this.props.auth.authenticated}
  17. />
  18. <Footer />
  19. </App>
  20. )
  21. }
  22. }
  23.  
  24. ---------------------------------------------------------------------------------------------------------------
  25.  
  26. routes.js
  27.  
  28. <ConnectedRouter>
  29. <Switch>
  30. <Route exact path="/user-profile" render={(props) => (
  31. !hasProfile && authenticated ? (<BuildProfile/>) :
  32. (<Redirect to={{ pathname: '/auth/createAccount'}}/>)
  33. <Route exact path="/user-profile/home" render={(props) => (
  34. hasProfile && authenticated ? (<Home/>) :
  35. (<Redirect to={{pathname: '/auth/createAccount'}}/>)
  36. </Switch>
  37. </ConnectedRouter>
  38.  
  39.  
  40. ---------------------------------------------------------------------------------------------------------------
  41.  
  42.  
  43. BuildProfile.js
  44.  
  45. User adds last name, addresses and phone. Then they are redirected to profile Home.
Add Comment
Please, Sign In to add comment