@@ -34,7 +34,8 @@ import {
34
34
openInNewTab ,
35
35
getDefaultSignature ,
36
36
onClickZoomIn ,
37
- onClickZoomOut
37
+ onClickZoomOut ,
38
+ fetchUrl
38
39
} from "../constant/Utils" ;
39
40
import LoaderWithMsg from "../primitives/LoaderWithMsg" ;
40
41
import HandleError from "../primitives/HandleError" ;
@@ -340,23 +341,17 @@ function PdfRequestFiles(props) {
340
341
}
341
342
setUnSignedSigners ( placeholdersOrSigners ) ;
342
343
setPdfDetails ( documentData ) ;
343
- setIsLoading ( {
344
- isLoad : false
345
- } ) ;
344
+ setIsLoading ( { isLoad : false } ) ;
346
345
} else if (
347
346
documentData === "Error: Something went wrong!" ||
348
347
( documentData . result && documentData . result . error )
349
348
) {
350
349
console . log ( "err in get template details " ) ;
351
350
setHandleError ( t ( "something-went-wrong-mssg" ) ) ;
352
- setIsLoading ( {
353
- isLoad : false
354
- } ) ;
351
+ setIsLoading ( { isLoad : false } ) ;
355
352
} else {
356
353
setHandleError ( t ( "no-data" ) ) ;
357
- setIsLoading ( {
358
- isLoad : false
359
- } ) ;
354
+ setIsLoading ( { isLoad : false } ) ;
360
355
}
361
356
} catch ( err ) {
362
357
console . log ( "err in get template details " , err ) ;
@@ -424,16 +419,11 @@ function PdfRequestFiles(props) {
424
419
}
425
420
if ( isCompleted ) {
426
421
setIsSigned ( true ) ;
427
- const data = {
428
- isCertificate : true ,
429
- isModal : true
430
- } ;
422
+ const data = { isCertificate : true , isModal : true } ;
431
423
setAlreadySign ( true ) ;
432
424
setIsCompleted ( data ) ;
433
425
setIsCelebration ( true ) ;
434
- setTimeout ( ( ) => {
435
- setIsCelebration ( false ) ;
436
- } , 5000 ) ;
426
+ setTimeout ( ( ) => setIsCelebration ( false ) , 5000 ) ;
437
427
} else if ( declined ) {
438
428
const currentDecline = {
439
429
currnt : "another" ,
@@ -449,9 +439,7 @@ function PdfRequestFiles(props) {
449
439
} // Check if the current signer is not a last signer and handle the complete message.
450
440
else if ( isNextUser ) {
451
441
setIsCelebration ( true ) ;
452
- setTimeout ( ( ) => {
453
- setIsCelebration ( false ) ;
454
- } , 5000 ) ;
442
+ setTimeout ( ( ) => setIsCelebration ( false ) , 5000 ) ;
455
443
setIsCompleted ( {
456
444
isModal : true ,
457
445
message : t ( "document-signed-alert-1" )
@@ -478,7 +466,8 @@ function PdfRequestFiles(props) {
478
466
documentData [ 0 ] . AuditTrail . length > 0 &&
479
467
documentData [ 0 ] . AuditTrail . filter (
480
468
( data ) =>
481
- data . UserPtr . objectId === currUserId && data . Activity === "Signed"
469
+ data . UserPtr ?. objectId === currUserId &&
470
+ data . Activity === "Signed"
482
471
) ;
483
472
if (
484
473
checkAlreadySign &&
@@ -558,15 +547,15 @@ function PdfRequestFiles(props) {
558
547
for ( const item of placeholdersOrSigners ) {
559
548
const checkEmail = item ?. email ;
560
549
//if email exist then compare user signed by using email else signers objectId
561
- const emailOrId = checkEmail ? item . email : item . objectId ;
550
+ const emailOrId = checkEmail ? item . email : item ? .objectId ;
562
551
//`isSignedSignature` variable to handle break loop whenever it get true
563
552
let isSignedSignature = false ;
564
553
//checking the signer who signed the document by using audit trail details.
565
554
//and save signedSigners and unsignedSigners details
566
555
for ( const doc of audittrailData ) {
567
556
const signedExist = checkEmail
568
- ? doc ?. UserPtr . Email
569
- : doc ?. UserPtr . objectId ;
557
+ ? doc ?. UserPtr ? .Email
558
+ : doc ?. UserPtr ? .objectId ;
570
559
571
560
if ( emailOrId === signedExist ) {
572
561
signers . push ( { ...item } ) ;
@@ -644,15 +633,11 @@ function PdfRequestFiles(props) {
644
633
( documentData . result && documentData . result . error )
645
634
) {
646
635
setHandleError ( t ( "something-went-wrong-mssg" ) ) ;
647
- setIsLoading ( {
648
- isLoad : false
649
- } ) ;
636
+ setIsLoading ( { isLoad : false } ) ;
650
637
console . log ( "err in getDocument cloud function " ) ;
651
638
} else {
652
639
setHandleError ( t ( "no-data" ) ) ;
653
- setIsUiLoading ( {
654
- isLoad : false
655
- } ) ;
640
+ setIsUiLoading ( { isLoad : false } ) ;
656
641
}
657
642
//function to get default signatur eof current user from `contracts_Signature` class
658
643
const defaultSignRes = await getDefaultSignature ( jsonSender . objectId ) ;
@@ -662,15 +647,11 @@ function PdfRequestFiles(props) {
662
647
} else if ( defaultSignRes ?. status === "error" ) {
663
648
setHandleError ( "Error: Something went wrong!" ) ;
664
649
}
665
- setIsLoading ( {
666
- isLoad : false
667
- } ) ;
650
+ setIsLoading ( { isLoad : false } ) ;
668
651
} catch ( err ) {
669
652
console . log ( "Error: error in getDocumentDetails" , err ) ;
670
653
setHandleError ( "Error: Something went wrong!" ) ;
671
- setIsLoading ( {
672
- isLoad : false
673
- } ) ;
654
+ setIsLoading ( { isLoad : false } ) ;
674
655
}
675
656
} ;
676
657
//function for embed signature or image url in pdf
@@ -1028,9 +1009,7 @@ function PdfRequestFiles(props) {
1028
1009
openSignUrl +
1029
1010
" target=_blank>here</a>.</p> </div></div></body> </html>"
1030
1011
} ;
1031
- await axios . post ( url , params , {
1032
- headers : headers
1033
- } ) ;
1012
+ await axios . post ( url , params , { headers : headers } ) ;
1034
1013
} catch ( error ) {
1035
1014
console . log ( "error" , error ) ;
1036
1015
}
@@ -1193,10 +1172,7 @@ function PdfRequestFiles(props) {
1193
1172
const img = new Image ( ) ;
1194
1173
img . src = defaultSignImg ;
1195
1174
if ( img . complete ) {
1196
- imgWH = {
1197
- width : img . width ,
1198
- height : img . height
1199
- } ;
1175
+ imgWH = { width : img . width , height : img . height } ;
1200
1176
}
1201
1177
}
1202
1178
//get current signer placeholder position data
@@ -1256,10 +1232,7 @@ function PdfRequestFiles(props) {
1256
1232
. then ( async ( result ) => {
1257
1233
const res = result . data ;
1258
1234
if ( res ) {
1259
- const currentDecline = {
1260
- currnt : "YouDeclined" ,
1261
- isDeclined : true
1262
- } ;
1235
+ const currentDecline = { currnt : "YouDeclined" , isDeclined : true } ;
1263
1236
setIsDecline ( currentDecline ) ;
1264
1237
setIsUiLoading ( false ) ;
1265
1238
const params = {
@@ -1318,10 +1291,7 @@ function PdfRequestFiles(props) {
1318
1291
x . signerObjId === signerObjectId ? { ...x , placeHolder : updatePlace } : x
1319
1292
) ;
1320
1293
setSignerPos ( updatesignerPos ) ;
1321
- setDefaultSignAlert ( {
1322
- isShow : false ,
1323
- alertMessage : ""
1324
- } ) ;
1294
+ setDefaultSignAlert ( { isShow : false , alertMessage : "" } ) ;
1325
1295
} ;
1326
1296
const handleDontShow = ( isChecked ) => {
1327
1297
setIsDontShow ( isChecked ) ;
@@ -1502,7 +1472,6 @@ function PdfRequestFiles(props) {
1502
1472
const SendOtp = async ( ) => {
1503
1473
try {
1504
1474
const params = { email : contact . email , docId : res . docId } ;
1505
-
1506
1475
const Otp = await axios . post (
1507
1476
`${ localStorage . getItem ( "baseUrl" ) } /functions/SendOTPMailV1` ,
1508
1477
params ,
@@ -1540,10 +1509,7 @@ function PdfRequestFiles(props) {
1540
1509
"Content-Type" : "application/json" ,
1541
1510
"X-Parse-Application-Id" : parseId
1542
1511
} ;
1543
- let body = {
1544
- email : contact . email ,
1545
- otp : otp
1546
- } ;
1512
+ let body = { email : contact . email , otp : otp } ;
1547
1513
let user = await axios . post ( url , body , { headers : headers } ) ;
1548
1514
if ( user . data . result === "Invalid Otp" ) {
1549
1515
alert ( t ( "invalid-otp" ) ) ;
@@ -1575,9 +1541,7 @@ function PdfRequestFiles(props) {
1575
1541
// document.getElementById("my_modal").close();
1576
1542
setIsPublicContact ( false ) ;
1577
1543
setIsPublicTemplate ( false ) ;
1578
- setIsLoading ( {
1579
- isLoad : false
1580
- } ) ;
1544
+ setIsLoading ( { isLoad : false } ) ;
1581
1545
setDocumentId ( res ?. docId ) ;
1582
1546
getDocumentDetails ( res ?. docId ) ;
1583
1547
}
@@ -1593,11 +1557,7 @@ function PdfRequestFiles(props) {
1593
1557
setLoading ( false ) ;
1594
1558
setIsOtp ( false ) ;
1595
1559
setOtp ( ) ;
1596
- setContact ( {
1597
- name : "" ,
1598
- email : "" ,
1599
- phone : ""
1600
- } ) ;
1560
+ setContact ( { name : "" , email : "" , phone : "" } ) ;
1601
1561
} ;
1602
1562
1603
1563
const clickOnZoomIn = ( ) => {
@@ -1606,6 +1566,11 @@ function PdfRequestFiles(props) {
1606
1566
const clickOnZoomOut = ( ) => {
1607
1567
onClickZoomOut ( zoomPercent , scale , setZoomPercent , setScale ) ;
1608
1568
} ;
1569
+ const handleDownloadBtn = async ( ) => {
1570
+ const url = pdfDetails ?. [ 0 ] ?. SignedUrl || pdfDetails ?. [ 0 ] ?. URL ;
1571
+ const name = pdfDetails ?. [ 0 ] ?. Name ;
1572
+ await fetchUrl ( url , name ) ;
1573
+ } ;
1609
1574
return (
1610
1575
< DndProvider backend = { HTML5Backend } >
1611
1576
< Title title = { props . templateId ? "Public Sign" : "Request Sign" } />
@@ -1696,9 +1661,9 @@ function PdfRequestFiles(props) {
1696
1661
headMsg = { t ( "document-decline" ) }
1697
1662
bodyMssg = {
1698
1663
isDecline . currnt === "Sure"
1699
- ? t ( "decline-alert-2 " )
1664
+ ? t ( "decline-alert-1 " )
1700
1665
: isDecline . currnt === "YouDeclined"
1701
- ? t ( "decline-alert-1 " )
1666
+ ? t ( "decline-alert-2 " )
1702
1667
: isDecline . currnt === "another" && t ( "decline-alert-3" )
1703
1668
}
1704
1669
footerMessage = { isDecline . currnt === "Sure" }
@@ -1710,6 +1675,8 @@ function PdfRequestFiles(props) {
1710
1675
show = { isExpired }
1711
1676
headMsg = { t ( "expired-doc-title" ) }
1712
1677
bodyMssg = { t ( "expired-on-mssg" , { expiredDate } ) }
1678
+ isDownloadBtn = { true }
1679
+ handleDownloadBtn = { handleDownloadBtn }
1713
1680
/>
1714
1681
{ ! isEmailVerified && (
1715
1682
< VerifyEmail
@@ -1723,7 +1690,6 @@ function PdfRequestFiles(props) {
1723
1690
handleResend = { handleResend }
1724
1691
/>
1725
1692
) }
1726
-
1727
1693
< ModalUi
1728
1694
isOpen = { isPublicContact }
1729
1695
title = { isOtp ? t ( "verify-email-1" ) : t ( "contact-details" ) }
0 commit comments