settings.js 841 B

12345678910111213141516171819202122232425262728
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { connect } from 'react-redux';
  4. import BodyWrapper from '../components/BodyWrapper';
  5. import Footer from '../components/Footer';
  6. import { authUser } from '../actions';
  7. import Settings from '../components/Settings';
  8. const SettingsPage = ({ isAuthenticated }) => (
  9. <BodyWrapper>
  10. {isAuthenticated ? <Settings /> : null}
  11. <Footer />
  12. </BodyWrapper>
  13. );
  14. SettingsPage.getInitialProps = ({ req, reduxStore }) => {
  15. const token = req && req.cookies && req.cookies.token;
  16. if (token && reduxStore) reduxStore.dispatch(authUser(token));
  17. return {};
  18. };
  19. SettingsPage.propTypes = {
  20. isAuthenticated: PropTypes.bool.isRequired,
  21. };
  22. const mapStateToProps = ({ auth: { isAuthenticated } }) => ({ isAuthenticated });
  23. export default connect(mapStateToProps)(SettingsPage);