File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ .error {
2+ font-family : sans-serif;
3+ font-weight : bold;
4+ color : # a33535 ;
5+ background-color : # e0caca ;
6+ padding : 5px ;
7+ text-align : center;
8+ }
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import './Error.css' ;
3+
4+ function Error ( props ) {
5+
6+ const { errorCode } = props ;
7+
8+ function getErrorMessage ( ) {
9+ switch ( errorCode ) {
10+ case 'grocery-list-not-found' :
11+ return 'Oops, we couldn\'t find your grocery list. Try creating a new one.' ;
12+ case 'add-list-item-error' :
13+ return 'Failed to add grocery item to list. Try again.' ;
14+ case 'create-list-error' :
15+ return 'Failed to create the grocery list. Try again.' ;
16+ case 'add-user-to-list-error' :
17+ return 'Failed to add user to the grocery list. Try again.' ;
18+ default :
19+ return ;
20+ }
21+ }
22+
23+ if ( errorCode ) {
24+ return (
25+ < p className = "error" >
26+ { getErrorMessage ( ) }
27+ </ p >
28+ ) ;
29+ }
30+
31+ return null ;
32+ } ;
33+
34+ export default Error ;
You can’t perform that action at this time.
0 commit comments