Skip to content

Commit ff7fc88

Browse files
committedJun 27, 2018
Video 21
1 parent 4e52a98 commit ff7fc88

File tree

44 files changed

+1678
-417
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1678
-417
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import styled from 'styled-components';
2+
import React from 'react';
3+
4+
import PropTypes from 'prop-types';
5+
6+
const ErrorStyles = styled.div`
7+
padding: 2rem;
8+
background: white;
9+
margin: 2rem 0;
10+
border: 1px solid rgba(0, 0, 0, 0.05);
11+
border-left: 5px solid red;
12+
p {
13+
margin: 0;
14+
font-weight: 100;
15+
}
16+
strong {
17+
margin-right: 1rem;
18+
}
19+
`;
20+
21+
const DisplayError = ({ error }) => {
22+
if (!error || !error.message) return null;
23+
if (error.networkError && error.networkError.result && error.networkError.result.errors.length) {
24+
return error.networkError.result.errors.map((error, i) => (
25+
<ErrorStyles key={i}>
26+
<p data-test="graphql-error">
27+
<strong>Shoot!</strong>
28+
{error.message.replace('GraphQL error: ', '')}
29+
</p>
30+
</ErrorStyles>
31+
));
32+
}
33+
return (
34+
<ErrorStyles>
35+
<p data-test="graphql-error">
36+
<strong>Shoot!</strong>
37+
{error.message.replace('GraphQL error: ', '')}
38+
</p>
39+
</ErrorStyles>
40+
);
41+
};
42+
43+
DisplayError.defaultProps = {
44+
error: {},
45+
};
46+
47+
DisplayError.propTypes = {
48+
error: PropTypes.object,
49+
};
50+
51+
export default DisplayError;

‎stepped-solutions/05/frontend/components/styles/CartStyles.js

-47
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.