stats.js 722 B

1234567891011121314151617181920212223242526272829
  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 Stats from '../components/Stats';
  7. import { authUser } from '../actions';
  8. const StatsPage = ({ id }) => (
  9. <BodyWrapper>
  10. <Stats id={id} />
  11. </BodyWrapper>
  12. );
  13. StatsPage.getInitialProps = ({ req, store, query }) => {
  14. const token = req && req.cookies && req.cookies.token;
  15. if (token && store) store.dispatch(authUser(token));
  16. return { id: query && query.id };
  17. };
  18. StatsPage.propTypes = {
  19. id: PropTypes.string,
  20. };
  21. StatsPage.defaultProps = {
  22. id: '',
  23. };
  24. export default withRedux(initialState)(StatsPage);