url-info.js 1.4 KB

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