@@ -29,6 +29,7 @@ const ReportTable = ({
29
29
const [ isDocErr , setIsDocErr ] = useState ( false ) ;
30
30
const [ isContactform , setIsContactform ] = useState ( false ) ;
31
31
const [ isDeleteModal , setIsDeleteModal ] = useState ( { } ) ;
32
+ const [ isRevoke , setIsRevoke ] = useState ( { } ) ;
32
33
const [ isShare , setIsShare ] = useState ( { } ) ;
33
34
const [ shareUrls , setShareUrls ] = useState ( [ ] ) ;
34
35
const [ copied , setCopied ] = useState ( false ) ;
@@ -200,6 +201,8 @@ const ReportTable = ({
200
201
setIsDeleteModal ( { [ item . objectId ] : true } ) ;
201
202
} else if ( act . action === "share" ) {
202
203
handleShare ( item ) ;
204
+ } else if ( act . action === "revoke" ) {
205
+ setIsRevoke ( { [ item . objectId ] : true } ) ;
203
206
}
204
207
} ;
205
208
// Get current list
@@ -260,7 +263,10 @@ const ReportTable = ({
260
263
setActLoader ( { } ) ;
261
264
}
262
265
} ;
263
- const handleCloseDeleteModal = ( ) => setIsDeleteModal ( { } ) ;
266
+ const handleClose = ( ) => {
267
+ setIsRevoke ( { } ) ;
268
+ setIsDeleteModal ( { } ) ;
269
+ } ;
264
270
265
271
const handleShare = ( item ) => {
266
272
setActLoader ( { [ item . objectId ] : true } ) ;
@@ -281,6 +287,46 @@ const ReportTable = ({
281
287
navigator . clipboard . writeText ( share . url ) ;
282
288
setCopied ( { ...copied , [ share . email ] : true } ) ;
283
289
} ;
290
+ //function to handle revoke/decline docment
291
+ const handleRevoke = async ( item ) => {
292
+ setIsRevoke ( { } ) ;
293
+ setActLoader ( { [ `${ item . objectId } ` ] : true } ) ;
294
+ const data = {
295
+ IsDeclined : true
296
+ } ;
297
+
298
+ await axios
299
+ . put (
300
+ `${ localStorage . getItem ( "baseUrl" ) } classes/${ localStorage . getItem (
301
+ "_appName"
302
+ ) } _Document/${ item . objectId } `,
303
+ data ,
304
+ {
305
+ headers : {
306
+ "Content-Type" : "application/json" ,
307
+ "X-Parse-Application-Id" : localStorage . getItem ( "parseAppId" ) ,
308
+ "X-Parse-Session-Token" : localStorage . getItem ( "accesstoken" )
309
+ }
310
+ }
311
+ )
312
+ . then ( async ( result ) => {
313
+ const res = result . data ;
314
+ if ( res ) {
315
+ setActLoader ( { } ) ;
316
+ setIsAlert ( true ) ;
317
+ setTimeout ( ( ) => setIsAlert ( false ) , 1500 ) ;
318
+ const upldatedList = List . filter ( ( x ) => x . objectId !== item . objectId ) ;
319
+ setList ( upldatedList ) ;
320
+ }
321
+ } )
322
+ . catch ( ( err ) => {
323
+ console . log ( "err" , err ) ;
324
+ setIsAlert ( true ) ;
325
+ setIsErr ( true ) ;
326
+ setTimeout ( ( ) => setIsAlert ( false ) , 1500 ) ;
327
+ setActLoader ( { } ) ;
328
+ } ) ;
329
+ } ;
284
330
return (
285
331
< div className = "relative" >
286
332
{ Object . keys ( actLoader ) ?. length > 0 && (
@@ -370,7 +416,7 @@ const ReportTable = ({
370
416
< ModalUi
371
417
isOpen
372
418
title = { "Delete Contact" }
373
- handleClose = { handleCloseDeleteModal }
419
+ handleClose = { handleClose }
374
420
>
375
421
< div className = "m-[20px]" >
376
422
< div className = "text-lg font-normal text-black" >
@@ -388,7 +434,7 @@ const ReportTable = ({
388
434
Yes
389
435
</ button >
390
436
< button
391
- onClick = { handleCloseDeleteModal }
437
+ onClick = { handleClose }
392
438
className = "px-4 py-1.5 text-black border-[1px] border-[#ccc] shadow-md rounded focus:outline-none"
393
439
style = { {
394
440
backgroundColor : modalCancelBtnColor
@@ -459,7 +505,7 @@ const ReportTable = ({
459
505
< ModalUi
460
506
isOpen
461
507
title = { "Delete Document" }
462
- handleClose = { handleCloseDeleteModal }
508
+ handleClose = { handleClose }
463
509
>
464
510
< div className = "m-[20px]" >
465
511
< div className = "text-lg font-normal text-black" >
@@ -477,7 +523,7 @@ const ReportTable = ({
477
523
Yes
478
524
</ button >
479
525
< button
480
- onClick = { handleCloseDeleteModal }
526
+ onClick = { handleClose }
481
527
className = "px-4 py-1.5 text-black border-[1px] border-[#ccc] shadow-md rounded focus:outline-none"
482
528
style = { {
483
529
backgroundColor : modalCancelBtnColor
@@ -531,6 +577,41 @@ const ReportTable = ({
531
577
</ div >
532
578
</ ModalUi >
533
579
) }
580
+ { isRevoke [ item . objectId ] && (
581
+ < ModalUi
582
+ isOpen
583
+ title = { "Delete Contact" }
584
+ handleClose = { handleClose }
585
+ >
586
+ < div className = "m-[20px]" >
587
+ < div className = "text-lg font-normal text-black" >
588
+ Are you sure you want to revoke/decline this
589
+ document?
590
+ </ div >
591
+ < hr className = "bg-[#ccc] mt-4 " />
592
+ < div className = "flex items-center mt-3 gap-2 text-white" >
593
+ < button
594
+ onClick = { ( ) => handleRevoke ( item ) }
595
+ className = "px-4 py-1.5 text-white rounded shadow-md text-center focus:outline-none "
596
+ style = { {
597
+ backgroundColor : modalSubmitBtnColor
598
+ } }
599
+ >
600
+ Yes
601
+ </ button >
602
+ < button
603
+ onClick = { handleClose }
604
+ className = "px-4 py-1.5 text-black border-[1px] border-[#ccc] shadow-md rounded focus:outline-none"
605
+ style = { {
606
+ backgroundColor : modalCancelBtnColor
607
+ } }
608
+ >
609
+ No
610
+ </ button >
611
+ </ div >
612
+ </ div >
613
+ </ ModalUi >
614
+ ) }
534
615
</ td >
535
616
</ tr >
536
617
)
0 commit comments