@@ -8,8 +8,6 @@ const FileUpload = (props) => {
8
8
const [ parseAppId ] = useState ( localStorage . getItem ( "parseAppId" ) ) ;
9
9
const [ _fileupload , setFileUpload ] = useState ( "" ) ;
10
10
const [ fileload , setfileload ] = useState ( false ) ;
11
-
12
- const [ localValue , setLocalValue ] = useState ( "" ) ;
13
11
const [ Message ] = useState ( false ) ;
14
12
const [ percentage , setpercentage ] = useState ( 0 ) ;
15
13
@@ -25,7 +23,6 @@ const FileUpload = (props) => {
25
23
const onChange = ( e ) => {
26
24
try {
27
25
let files = e . target . files ;
28
- setLocalValue ( e . target . files ) ;
29
26
if ( typeof files [ 0 ] !== "undefined" ) {
30
27
if ( props . schema . filetypes && props . schema . filetypes . length > 0 ) {
31
28
var fileName = files [ 0 ] . name ;
@@ -257,58 +254,53 @@ const FileUpload = (props) => {
257
254
</ div >
258
255
259
256
< >
260
- { localValue ? (
261
- < input
262
- type = "file"
263
- id = "hashfile"
264
- style = { {
265
- border : "1px solid #ccc" ,
266
- color : "gray" ,
267
- backgroundColor : "white" ,
268
- padding : "5px 10px" ,
269
- borderRadius : "4px" ,
270
- fontSize : "13px" ,
271
- width : "100%" ,
272
- fontWeight : "bold"
273
- } }
274
- accept = "application/pdf,application/vnd.ms-excel"
275
- onChange = { onChange }
276
- />
277
- ) : props . formData ? (
278
- < div
279
- style = { {
280
- border : "1px solid #ccc" ,
281
- color : "gray" ,
282
- backgroundColor : "white" ,
283
- padding : "5px 10px" ,
284
- borderRadius : "4px" ,
285
- fontSize : "13px" ,
286
- width : "100%" ,
287
- fontWeight : "bold"
288
- } }
289
- >
290
- file selected : { props . formData . split ( "/" ) [ 3 ] }
257
+ { props . formData ? (
258
+ < div className = "flex gap-2 justify-center items-center" >
259
+ < div className = "flex justify-between items-center px-2 py-[6px] w-full font-bold rounded border-[1px] border-[#ccc] text-gray-500 bg-white text-[13px]" >
260
+ < div className = "break-all" >
261
+ file selected : { props . formData . split ( "/" ) [ 3 ] }
262
+ </ div >
263
+ < div
264
+ onClick = { ( ) => {
265
+ console . log ( "clicked" ) ;
266
+ setFileUpload ( [ ] ) ;
267
+ props . onChange ( undefined ) ;
268
+ } }
269
+ className = "cursor-pointer px-[10px] text-base font-bold bg-white"
270
+ >
271
+ X
272
+ </ div >
273
+ </ div >
274
+ < DropboxChooser
275
+ onSuccess = { dropboxSuccess }
276
+ onCancel = { dropboxCancel }
277
+ />
291
278
</ div >
292
279
) : (
293
- < input
294
- type = "file"
295
- id = "hashfile"
296
- style = { {
297
- border : "1px solid #ccc" ,
298
- color : "gray" ,
299
- backgroundColor : "white" ,
300
- padding : "5px 10px" ,
301
- borderRadius : "4px" ,
302
- fontSize : "13px" ,
303
- width : "100%" ,
304
- fontWeight : "bold"
305
- } }
306
- accept = "application/pdf,application/vnd.ms-excel"
307
- onChange = { onChange }
308
- />
280
+ < div className = "flex gap-2 justify-center items-center" >
281
+ < input
282
+ type = "file"
283
+ id = "hashfile"
284
+ style = { {
285
+ border : "1px solid #ccc" ,
286
+ color : "gray" ,
287
+ backgroundColor : "white" ,
288
+ padding : "5px 10px" ,
289
+ borderRadius : "4px" ,
290
+ fontSize : "13px" ,
291
+ width : "100%" ,
292
+ fontWeight : "bold"
293
+ } }
294
+ accept = "application/pdf,application/vnd.ms-excel"
295
+ onChange = { onChange }
296
+ />
297
+ < DropboxChooser
298
+ onSuccess = { dropboxSuccess }
299
+ onCancel = { dropboxCancel }
300
+ />
301
+ </ div >
309
302
) }
310
303
</ >
311
- < DropboxChooser onSuccess = { dropboxSuccess } onCancel = { dropboxCancel } />
312
304
</ React . Fragment >
313
305
) ;
314
306
} ;
0 commit comments