settings.js 871 B

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