@@ -104,7 +104,6 @@ function PdfRequestFiles() {
104
104
const [ currWidgetsDetails , setCurrWidgetsDetails ] = useState ( { } ) ;
105
105
const [ isSubscriptionExpired , setIsSubscriptionExpired ] = useState ( false ) ;
106
106
const [ extUserId , setExtUserId ] = useState ( "" ) ;
107
- const [ pdfArrayBuffer , setPdfArrayBuffer ] = useState ( "" ) ;
108
107
const [ isEmailVerified , setIsEmailVerified ] = useState ( true ) ;
109
108
const [ isVerifyModal , setIsVerifyModal ] = useState ( false ) ;
110
109
const [ otp , setOtp ] = useState ( "" ) ;
@@ -225,16 +224,6 @@ function PdfRequestFiles() {
225
224
//getting document details
226
225
const documentData = await contractDocument ( documentId ) ;
227
226
if ( documentData && documentData . length > 0 ) {
228
- const url =
229
- documentData [ 0 ] && ( documentData [ 0 ] ?. SignedUrl || documentData [ 0 ] ?. URL ) ;
230
- //convert document url in array buffer format to use embed widgets in pdf using pdf-lib
231
- const arrayBuffer = await convertPdfArrayBuffer ( url ) ;
232
- if ( arrayBuffer === "Error" ) {
233
- setHandleError ( "Error: Something went wrong!" ) ;
234
- } else {
235
- setPdfArrayBuffer ( arrayBuffer ) ;
236
- }
237
-
238
227
setExtUserId ( documentData [ 0 ] ?. ExtUserPtr ?. objectId ) ;
239
228
const isCompleted =
240
229
documentData [ 0 ] . IsCompleted && documentData [ 0 ] . IsCompleted ;
@@ -642,9 +631,32 @@ function PdfRequestFiles() {
642
631
setWidgetsTour ( true ) ;
643
632
} else {
644
633
setIsUiLoading ( true ) ;
634
+
645
635
const pngUrl = checkUser [ 0 ] . placeHolder ;
636
+ let pdfArrBuffer ;
637
+ //`contractDocument` function used to get updated SignedUrl
638
+ //resolved issue of sign document by multiple signers simultaneously
639
+ const documentData = await contractDocument ( documentId ) ;
640
+ if ( documentData && documentData . length > 0 ) {
641
+ const url = documentData [ 0 ] ?. SignedUrl || documentData [ 0 ] ?. URL ;
642
+ //convert document url in array buffer format to use embed widgets in pdf using pdf-lib
643
+ const arrayBuffer = await convertPdfArrayBuffer ( url ) ;
644
+ if ( arrayBuffer === "Error" ) {
645
+ setHandleError ( "Error: invalid document!" ) ;
646
+ } else {
647
+ pdfArrBuffer = arrayBuffer ;
648
+ }
649
+ } else if (
650
+ documentData === "Error: Something went wrong!" ||
651
+ ( documentData . result && documentData . result . error )
652
+ ) {
653
+ setHandleError ( "Error: Something went wrong!" ) ;
654
+ } else {
655
+ setHandleError ( "Document not Found!" ) ;
656
+ }
657
+
646
658
// Load a PDFDocument from the existing PDF bytes
647
- const existingPdfBytes = pdfArrayBuffer ;
659
+ const existingPdfBytes = pdfArrBuffer ;
648
660
try {
649
661
const pdfDoc = await PDFDocument . load ( existingPdfBytes ) ;
650
662
const isSignYourSelfFlow = false ;
0 commit comments