File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import PropTypes from 'prop-types';
5
5
const FileUploadTarget = props => {
6
6
const {
7
7
className,
8
+ error,
8
9
instructions,
9
10
handleSelectedFile,
10
11
handleDragOver,
@@ -47,15 +48,22 @@ const FileUploadTarget = props => {
47
48
className = "Button Button--default"
48
49
onChange = { handleSelectedFile }
49
50
/>
51
+ { error && error . graphQLErrors && (
52
+ < h4 className = "text-red px-2" >
53
+ Failed to upload: { error . graphQLErrors . map ( err => err . message ) }
54
+ </ h4 >
55
+ ) }
50
56
</ form >
51
57
) ;
52
58
} ;
53
59
54
60
FileUploadTarget . propTypes = {
55
61
/** any additional classes that should be added to the container */
56
62
className : PropTypes . string ,
57
- /** if cursor is currently dragging over the component
58
- dragging: PropTypes.boolean,
63
+ /** if cursor is currently dragging over the component */
64
+ dragging : PropTypes . bool ,
65
+ /** Errors from graphQL */
66
+ errors : PropTypes . object ,
59
67
/** add helpful instruction about how to drag and drop files */
60
68
instructions : PropTypes . string ,
61
69
/** operation when component is dragged over */
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ const UploadContainer = props => {
45
45
} )
46
46
. catch ( err => {
47
47
console . log ( err ) ;
48
+ alert ( 'Failed to upload file.' ) ;
48
49
} ) ;
49
50
} ;
50
51
@@ -74,8 +75,9 @@ const UploadContainer = props => {
74
75
} ,
75
76
] }
76
77
>
77
- { ( createFile , { data} ) => (
78
+ { ( createFile , { data, error } ) => (
78
79
< FileUploadTarget
80
+ error = { error }
79
81
dragging = { dragging }
80
82
handleDragOver = { handleDragOver }
81
83
onDragEnter = { handleDragEnter }
You can’t perform that action at this time.
0 commit comments