@@ -32,7 +32,8 @@ import {
32
32
contactBook ,
33
33
handleDownloadPdf ,
34
34
handleToPrint ,
35
- handleDownloadCertificate
35
+ handleDownloadCertificate ,
36
+ darkenColor
36
37
} from "../constant/Utils" ;
37
38
import Loader from "../primitives/LoaderWithMsg" ;
38
39
import HandleError from "../primitives/HandleError" ;
@@ -74,7 +75,7 @@ function PdfRequestFiles() {
74
75
const [ selectWidgetId , setSelectWidgetId ] = useState ( "" ) ;
75
76
const [ otpLoader , setOtpLoader ] = useState ( false ) ;
76
77
const [ isCelebration , setIsCelebration ] = useState ( false ) ;
77
- const [ requestSignTour , setRequestSignTour ] = useState ( true ) ;
78
+ const [ requestSignTour , setRequestSignTour ] = useState ( false ) ;
78
79
const [ tourStatus , setTourStatus ] = useState ( [ ] ) ;
79
80
const [ isLoading , setIsLoading ] = useState ( {
80
81
isLoad : true ,
@@ -296,6 +297,10 @@ function PdfRequestFiles() {
296
297
setExpiredDate ( expireDateFormat ) ;
297
298
} // Check if the current signer is not a last signer and handle the complete message.
298
299
else if ( isNextUser ) {
300
+ setIsCelebration ( true ) ;
301
+ setTimeout ( ( ) => {
302
+ setIsCelebration ( false ) ;
303
+ } , 5000 ) ;
299
304
setIsCompleted ( {
300
305
isModal : true ,
301
306
message :
@@ -330,7 +335,7 @@ function PdfRequestFiles() {
330
335
}
331
336
}
332
337
}
333
- const checkDocIdExist =
338
+ const audittrailData =
334
339
documentData [ 0 ] . AuditTrail &&
335
340
documentData [ 0 ] . AuditTrail . length > 0 &&
336
341
documentData [ 0 ] . AuditTrail . filter ( ( data ) => data . Activity === "Signed" ) ;
@@ -398,41 +403,49 @@ function PdfRequestFiles() {
398
403
399
404
let signers = [ ] ;
400
405
let unSignedSigner = [ ] ;
406
+ //`emailExist` variable to handle condition for quick send flow and show unsigned signers list
407
+ const emailExist = documentData [ 0 ] . Placeholders [ 0 ] ?. email ;
401
408
402
- //check document is signed or not
403
- if ( checkDocIdExist && checkDocIdExist . length > 0 ) {
409
+ //condition to check already signed document by someone
410
+ if ( audittrailData && audittrailData . length > 0 ) {
404
411
setIsDocId ( true ) ;
405
- const signerRes = documentData [ 0 ] . Signers ;
406
- //comparison auditTrail user details with signers user details
407
- for ( let i = 0 ; i < signerRes . length ; i ++ ) {
408
- const signerId = signerRes [ i ] . objectId ;
412
+ const placeholdersOrSigners = emailExist
413
+ ? documentData [ 0 ] . Placeholders
414
+ : documentData [ 0 ] . Signers ;
409
415
416
+ for ( const item of placeholdersOrSigners ) {
417
+ //if email exist then compare user signed by using email else signers objectId
418
+ const emailOrId = emailExist ? item . email : item . objectId ;
419
+ //`isSignedSignature` variable to handle break loop whenever it get true
410
420
let isSignedSignature = false ;
411
- for ( let j = 0 ; j < checkDocIdExist . length ; j ++ ) {
412
- const signedExist =
413
- checkDocIdExist [ j ] && checkDocIdExist [ j ] . UserPtr . objectId ;
414
- //checking signerObjId and auditTrail User objId
415
- // if match then add signed data in signer array and break loop
421
+ //checking the signer who signed the document by using audit trail details.
422
+ //and save signedSigners and unsignedSigners details
423
+ for ( const doc of audittrailData ) {
424
+ const signedExist = emailExist
425
+ ? doc ?. UserPtr . Email
426
+ : doc ?. UserPtr . objectId ;
416
427
417
- if ( signerId === signedExist ) {
418
- signers . push ( { ...signerRes [ i ] , ... signerRes [ i ] } ) ;
428
+ if ( emailOrId === signedExist ) {
429
+ signers . push ( { ...item } ) ;
419
430
isSignedSignature = true ;
420
431
break ;
421
432
}
422
- // if does not match then add unsigned data in unSignedSigner array
423
433
}
424
434
if ( ! isSignedSignature ) {
425
- unSignedSigner . push ( { ...signerRes [ i ] , ... signerRes [ i ] } ) ;
435
+ unSignedSigner . push ( { ...item } ) ;
426
436
}
427
437
}
428
438
setSignedSigners ( signers ) ;
429
439
setUnSignedSigners ( unSignedSigner ) ;
430
440
setSignerPos ( documentData [ 0 ] . Placeholders ) ;
431
441
} else {
442
+ //else condition is show there are no details in audit trail then direct push all signers details
443
+ //in unsignedsigners array
432
444
let unsigned = [ ] ;
433
- for ( let i = 0 ; i < documentData . length ; i ++ ) {
434
- unsigned . push ( documentData [ i ] . Signers ) ;
435
- }
445
+ const placeholdersOrSigners = emailExist
446
+ ? documentData [ 0 ] . Placeholders
447
+ : documentData [ 0 ] . Signers ;
448
+ unsigned . push ( placeholdersOrSigners ) ;
436
449
setUnSignedSigners ( unsigned [ 0 ] ) ;
437
450
setSignerPos ( documentData [ 0 ] . Placeholders ) ;
438
451
}
@@ -447,7 +460,7 @@ function PdfRequestFiles() {
447
460
declined ||
448
461
currDate > expireUpdateDate
449
462
) {
450
- setRequestSignTour ( false ) ;
463
+ setRequestSignTour ( true ) ;
451
464
} else {
452
465
//else condition to check current user exist in contracts_Users class and check tour message status
453
466
//if not then check user exist in contracts_Contactbook class and check tour message status
@@ -463,33 +476,25 @@ function PdfRequestFiles() {
463
476
setContractName ( "_Users" ) ;
464
477
currUserId = res [ 0 ] . objectId ;
465
478
setSignerUserId ( currUserId ) ;
466
- const tourstatus = res [ 0 ] . TourStatus && res [ 0 ] . TourStatus ;
467
- if ( tourstatus && tourstatus . length > 0 ) {
468
- setTourStatus ( tourstatus ) ;
469
- const checkTourRequestSign = tourstatus . filter (
470
- ( data ) => data . requestSign
471
- ) ;
472
- if ( checkTourRequestSign && checkTourRequestSign . length > 0 ) {
473
- setRequestSignTour ( checkTourRequestSign [ 0 ] . requestSign ) ;
474
- }
479
+ const tourData = res [ 0 ] . TourStatus && res [ 0 ] . TourStatus ;
480
+ if ( tourData && tourData . length > 0 ) {
481
+ setTourStatus ( tourData ) ;
482
+ setRequestSignTour ( tourData [ 0 ] ?. requestSign || false ) ;
475
483
}
476
484
} else if ( res ?. length === 0 ) {
477
485
const res = await contactBook ( currUserId ) ;
486
+
478
487
if ( res === "Error: Something went wrong!" ) {
479
488
setHandleError ( "Error: Something went wrong!" ) ;
480
489
} else if ( res [ 0 ] && res . length ) {
481
490
setContractName ( "_Contactbook" ) ;
482
491
const objectId = res [ 0 ] . objectId ;
483
492
setSignerUserId ( objectId ) ;
484
- const tourstatus = res [ 0 ] . TourStatus && res [ 0 ] . TourStatus ;
485
- if ( tourstatus && tourstatus . length > 0 ) {
486
- setTourStatus ( tourstatus ) ;
487
- const checkTourRequestSign = tourstatus . filter (
488
- ( data ) => data . requestSign
489
- ) ;
490
- if ( checkTourRequestSign && checkTourRequestSign . length > 0 ) {
491
- setRequestSignTour ( checkTourRequestSign [ 0 ] . requestSign ) ;
492
- }
493
+ const tourData = res [ 0 ] . TourStatus && res [ 0 ] . TourStatus ;
494
+
495
+ if ( tourData && tourData . length > 0 ) {
496
+ setTourStatus ( tourData ) ;
497
+ setRequestSignTour ( tourData [ 0 ] ?. requestSign || false ) ;
493
498
}
494
499
} else if ( res . length === 0 ) {
495
500
setHandleError ( "Error: User does not exist!" ) ;
@@ -552,7 +557,6 @@ function PdfRequestFiles() {
552
557
setIsLoading ( loadObj ) ;
553
558
} ) ;
554
559
} ;
555
-
556
560
//function for embed signature or image url in pdf
557
561
async function embedWidgetsData ( ) {
558
562
try {
@@ -1109,9 +1113,19 @@ function PdfRequestFiles() {
1109
1113
} ;
1110
1114
1111
1115
const checkSignerBackColor = ( obj ) => {
1112
- const data = signerPos . filter ( ( data ) => data . signerObjId === obj . objectId ) ;
1116
+ let data = "" ;
1117
+ if ( obj ?. Id ) {
1118
+ data = signerPos . filter ( ( data ) => data . Id === obj . Id ) ;
1119
+ } else {
1120
+ data = signerPos . filter ( ( data ) => data . signerObjId === obj . objectId ) ;
1121
+ }
1113
1122
return data && data . length > 0 && data [ 0 ] . blockColor ;
1114
1123
} ;
1124
+ const checkUserNameColor = ( obj ) => {
1125
+ const getBackColor = checkSignerBackColor ( obj ) ;
1126
+ const color = darkenColor ( getBackColor , 0.4 ) ;
1127
+ return color ;
1128
+ } ;
1115
1129
1116
1130
//function for set decline true on press decline button
1117
1131
const declineDoc = async ( ) => {
@@ -1210,7 +1224,7 @@ function PdfRequestFiles() {
1210
1224
} ;
1211
1225
//function to close tour and save tour status
1212
1226
const closeRequestSignTour = async ( ) => {
1213
- setRequestSignTour ( false ) ;
1227
+ setRequestSignTour ( true ) ;
1214
1228
if ( isDontShow ) {
1215
1229
let updatedTourStatus = [ ] ;
1216
1230
if ( tourStatus . length > 0 ) {
@@ -1332,7 +1346,6 @@ function PdfRequestFiles() {
1332
1346
/>
1333
1347
) ;
1334
1348
} ;
1335
-
1336
1349
return (
1337
1350
< DndProvider backend = { HTML5Backend } >
1338
1351
< Title title = { "Request Sign" } />
@@ -1401,7 +1414,7 @@ function PdfRequestFiles() {
1401
1414
} }
1402
1415
ref = { divRef }
1403
1416
>
1404
- { requestSignTour && requestSignTourFunction ( ) }
1417
+ { ! requestSignTour && requestSignTourFunction ( ) }
1405
1418
< ModalUi
1406
1419
headerColor = { "#dc3545" }
1407
1420
isOpen = { isAlert . isShow }
@@ -1781,7 +1794,7 @@ function PdfRequestFiles() {
1781
1794
< div
1782
1795
className = "signerStyle"
1783
1796
style = { {
1784
- background : "#abd1d0" ,
1797
+ background : checkUserNameColor ( obj ) ,
1785
1798
width : 30 ,
1786
1799
height : 30 ,
1787
1800
display : "flex" ,
@@ -1800,7 +1813,7 @@ function PdfRequestFiles() {
1800
1813
textTransform : "uppercase"
1801
1814
} }
1802
1815
>
1803
- { getFirstLetter ( obj . Name ) }
1816
+ { getFirstLetter ( obj ? .Name || obj ?. Role ) }
1804
1817
</ span >
1805
1818
</ div >
1806
1819
< div
@@ -1809,9 +1822,11 @@ function PdfRequestFiles() {
1809
1822
flexDirection : "column"
1810
1823
} }
1811
1824
>
1812
- < span className = "userName" > { obj . Name } </ span >
1825
+ < span className = "userName" >
1826
+ { obj ?. Name || obj ?. Role }
1827
+ </ span >
1813
1828
< span className = "useEmail" >
1814
- { obj . Email }
1829
+ { obj ? .Email || obj ?. email }
1815
1830
</ span >
1816
1831
</ div >
1817
1832
</ div >
@@ -1850,7 +1865,7 @@ function PdfRequestFiles() {
1850
1865
< div
1851
1866
className = "signerStyle"
1852
1867
style = { {
1853
- background : "#abd1d0" ,
1868
+ background : checkUserNameColor ( obj ) ,
1854
1869
width : 30 ,
1855
1870
height : 30 ,
1856
1871
display : "flex" ,
@@ -1869,7 +1884,7 @@ function PdfRequestFiles() {
1869
1884
textTransform : "uppercase"
1870
1885
} }
1871
1886
>
1872
- { getFirstLetter ( obj . Name ) }
1887
+ { getFirstLetter ( obj ? .Name || obj ?. email ) }
1873
1888
</ span >
1874
1889
</ div >
1875
1890
< div
@@ -1878,9 +1893,11 @@ function PdfRequestFiles() {
1878
1893
flexDirection : "column"
1879
1894
} }
1880
1895
>
1881
- < span className = "userName" > { obj . Name } </ span >
1896
+ < span className = "userName" >
1897
+ { obj ?. Name || obj ?. Role }
1898
+ </ span >
1882
1899
< span className = "useEmail" >
1883
- { obj . Email }
1900
+ { obj ? .Email || obj ?. email }
1884
1901
</ span >
1885
1902
</ div >
1886
1903
< hr />
0 commit comments