Guest User

Untitled

a guest
Jun 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { connect } from 'react-redux';
  3. import { bindActionCreators } from 'redux';
  4. import { Route, Switch, withRouter } from 'react-router-dom';
  5.  
  6. // Import components here
  7. // Just showing one for brevity
  8. import Home from '../components/home/Home';
  9.  
  10. import * as appActions from '../actions/app-actions';
  11.  
  12. class App extends Component {
  13.  
  14. constructor(props) {
  15.  
  16. super(props);
  17. }
  18.  
  19. render() {
  20.  
  21. return(
  22.  
  23. <div>
  24. <Switch>
  25. <Route exact path="/member" component={Home} />
  26. <Route exact path="/member/accounts" component={Accounts} />
  27. <Route exact path="/member/projects" component={ProjectsList} />
  28. <Route path="/member/projects/profile/:id" component={ProjectProfile} />|
  29. <Route exact path="/member/tasks" component={TasksList} />
  30. <Route path="/member/tasks/profile/:id" component={TaskProfile} />
  31. </Switch>
  32. </div>
  33. );
  34.  
  35. }
  36. }
  37.  
  38. function mapStateToProps(state) {
  39.  
  40. return {
  41. member: state.member.memberData
  42. }
  43. }
  44.  
  45. function mapDispatchToProps(dispatch) {
  46.  
  47. return {
  48.  
  49. actions: bindActionCreators(appActions, dispatch)
  50. };
  51. }
  52.  
  53. export default withRouter(connect(mapStateToProps, mapDispatchToProps)(App));
  54.  
  55. import React, { Component } from 'react'
  56. import { connect } from 'react-redux';
  57. import { bindActionCreators } from 'redux';
  58.  
  59. // Actions
  60. import * as projectProfileActions from '../../../actions/project-profile-actions';
  61.  
  62. // Components
  63. import Desktop from './ProjectProfileDesktop';
  64. import Mobile from './ProjectProfileMobile';
  65.  
  66. class ProjectProfile extends Component {
  67.  
  68. constructor(props) {
  69.  
  70. super(props);
  71. };
  72.  
  73. componentDidMount() {
  74.  
  75. const id = this.props.match.params.id;
  76. this.props.actions.getData(id);
  77. }
  78.  
  79. render() {
  80.  
  81. return (
  82. <div className="height-100 width-100">
  83. <div className="height-100 width-100 row row-clean">
  84. {this.props.ui.isDesktop || this.props.ui.isTablet ? <Desktop />
  85. : this.props.ui.isMobile ? <Mobile />
  86. : null}
  87. </div>
  88. </div>
  89. );
  90. }
  91. }
  92.  
  93. function mapStateToProps(state) {
  94. return {
  95. ui: state.app.window
  96. };
  97. }
  98.  
  99. function mapDispatchToProps(dispatch) {
  100.  
  101. return {
  102. actions: bindActionCreators(projectProfileActions, dispatch)
  103. };
  104. }
  105.  
  106. export default connect(mapStateToProps, mapDispatchToProps)(ProjectProfile);
  107.  
  108. render(
  109. <Provider store={store}>
  110. <BrowserRouter history={browserHistory}>
  111. <StripeProvider apiKey="my_key">
  112. <App />
  113. </StripeProvider>
  114. </BrowserRouter>
  115. </Provider>,
  116. document.getElementById('root')
  117. );
Add Comment
Please, Sign In to add comment