@@ -17,12 +17,16 @@ export default {
17
17
export const Basic = {
18
18
name : 'Basic' ,
19
19
render : function ( { onChange, ...args } ) {
20
- const handleChange = ( file ) => {
21
- onChange ( file ) ;
22
- alert (
23
- `${ file . name } was uploaded, it was last modified at ${ new Date ( file . lastModified ) . toLocaleDateString ( 'en-us' ) } `
24
- ) ;
20
+ const handleChange = ( files ) => {
21
+ onChange ( files ) ;
22
+ Array . from ( files ) . forEach ( ( file ) => {
23
+ const date = new Date ( file . lastModified ) . toLocaleDateString ( 'en-us' ) ;
24
+ console . log (
25
+ file . name + 'was uploaded, it was last modified at ' + date
26
+ ) ;
27
+ } ) ;
25
28
} ;
29
+
26
30
return < MultiUpload { ...args } onChange = { handleChange } /> ;
27
31
} ,
28
32
args : {
@@ -43,12 +47,16 @@ export const Basic = {
43
47
export const Hint = {
44
48
name : 'Hint' ,
45
49
render : function ( { onChange, ...args } ) {
46
- const handleChange = ( file ) => {
47
- onChange ( file ) ;
48
- alert (
49
- `${ file . name } was uploaded, it was last modified at ${ new Date ( file . lastModified ) . toLocaleDateString ( 'en-us' ) } `
50
- ) ;
50
+ const handleChange = ( files ) => {
51
+ onChange ( files ) ;
52
+ Array . from ( files ) . forEach ( ( file ) => {
53
+ const date = new Date ( file . lastModified ) . toLocaleDateString ( 'en-us' ) ;
54
+ console . log (
55
+ file . name + 'was uploaded, it was last modified at ' + date
56
+ ) ;
57
+ } ) ;
51
58
} ;
59
+
52
60
return < MultiUpload { ...args } onChange = { handleChange } /> ;
53
61
} ,
54
62
args : {
@@ -73,12 +81,16 @@ export const Hint = {
73
81
export const Error = {
74
82
name : 'Error' ,
75
83
render : function ( { onChange, ...args } ) {
76
- const handleChange = ( file ) => {
77
- onChange ( file ) ;
78
- alert (
79
- `${ file . name } was uploaded, it was last modified at ${ new Date ( file . lastModified ) . toLocaleDateString ( 'en-us' ) } `
80
- ) ;
84
+ const handleChange = ( files ) => {
85
+ onChange ( files ) ;
86
+ Array . from ( files ) . forEach ( ( file ) => {
87
+ const date = new Date ( file . lastModified ) . toLocaleDateString ( 'en-us' ) ;
88
+ console . log (
89
+ file . name + 'was uploaded, it was last modified at ' + date
90
+ ) ;
91
+ } ) ;
81
92
} ;
93
+
82
94
return < MultiUpload { ...args } onChange = { handleChange } /> ;
83
95
} ,
84
96
args : {
@@ -91,7 +103,6 @@ export const Error = {
91
103
className : 'govuk-file-upload govuk-file-upload--error' ,
92
104
'aria-describedby' : 'govuk-file-upload govuk-file-upload--error' ,
93
105
} ,
94
- label : 'Upload a file' ,
95
106
labelProperties : {
96
107
className : 'govuk-label' ,
97
108
} ,
0 commit comments