url-info.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import React, { Component } from 'react';
  2. import PropTypes from 'prop-types';
  3. import styled from 'styled-components';
  4. import withRedux from 'next-redux-wrapper';
  5. import initialState from '../store';
  6. import BodyWrapper from '../components/BodyWrapper';
  7. import Footer from '../components/Footer';
  8. import { authUser } from '../actions';
  9. const Wrapper = styled.div`
  10. display: flex;
  11. flex: 1 1 100%;
  12. flex-direction: column;
  13. align-items: cetner;
  14. `;
  15. const Title = styled.h3`
  16. font-size: 28px;
  17. font-weight: 300;
  18. text-align: center;
  19. margin: 24px 0;
  20. @media only screen and (max-width: 448px) {
  21. font-size: 18px;
  22. }
  23. `;
  24. const Target = styled.h3`
  25. font-size: 18px;
  26. text-align: center;
  27. @media only screen and (max-width: 448px) {
  28. font-size: 16px;
  29. }
  30. `;
  31. class UrlInfoPage extends Component {
  32. static getInitialProps({ query, req, store }) {
  33. const token = req && req.cookies && req.cookies.token;
  34. if (token && store) store.dispatch(authUser(token));
  35. return { query };
  36. }
  37. render() {
  38. if (!this.props.query) {
  39. return (
  40. <BodyWrapper>
  41. <Title>404 | Not found.</Title>
  42. </BodyWrapper>
  43. );
  44. }
  45. return (
  46. <BodyWrapper>
  47. <Wrapper>
  48. <Title>Target:</Title>
  49. <Target>{this.props.query}</Target>
  50. </Wrapper>
  51. <Footer />
  52. </BodyWrapper>
  53. );
  54. }
  55. }
  56. UrlInfoPage.propTypes = {
  57. query: PropTypes.string,
  58. };
  59. UrlInfoPage.defaultProps = {
  60. query: null,
  61. };
  62. export default withRedux(initialState)(UrlInfoPage);