summaryrefslogtreecommitdiffstats
path: root/frontend/components/Page.js
blob: 93cd7c99f243f67893b370de3e7dd41bf15e8975 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import styled from 'styled-components';
import Header from './Header';
import Meta from './Meta';
import Nav from './Nav';
import CartList from './CartList';
import { Component } from 'react';

class ErrorBoundary extends Component {
  state = {
    error: null,
    errorInfo: null,
  };
  componentDidCatch(error, errorInfo) {
    console.log('Caught an erorrror!');
    this.setState({ error, errorInfo });
  }
  render() {
    if (this.state.error) {
      return <p>Shit! AN error! {this.state.error.message}</p>;
    }
    return this.props.children;
  }
}

const StyledPage = styled.div`
  font-family: sans-serif;
  color: #303030;
  background: #efc600;
  padding: 100px;
`;

const Page = ({ children }) => (
  <StyledPage className="main">
    <ErrorBoundary>
      <Meta />
      <Nav />
      <Header />
      {/* <CartList /> */}
      {children}
    </ErrorBoundary>
  </StyledPage>
);

export default Page;