@@ -300,58 +300,66 @@ function PdfRequestFiles(props) {
300
300
templateDeatils . data && templateDeatils . data . result
301
301
? [ templateDeatils . data . result ]
302
302
: [ ] ;
303
-
304
- if ( documentData && documentData . length > 0 ) {
305
- const url =
306
- documentData [ 0 ] &&
307
- ( documentData [ 0 ] ?. SignedUrl || documentData [ 0 ] ?. URL ) ;
308
- if ( url ) {
309
- //convert document url in array buffer format to use embed widgets in pdf using pdf-lib
310
- const arrayBuffer = await convertPdfArrayBuffer ( url ) ;
311
- if ( arrayBuffer === "Error" ) {
312
- setHandleError ( t ( "something-went-wrong-mssg" ) ) ;
303
+ if ( documentData && documentData [ 0 ] ?. error ) {
304
+ props ?. setTemplateStatus ( {
305
+ status : "Invalid"
306
+ } ) ;
307
+ } else if ( documentData && documentData . length > 0 ) {
308
+ if ( documentData [ 0 ] ?. IsPublic ) {
309
+ props ?. setTemplateStatus ( {
310
+ status : "Success"
311
+ } ) ;
312
+ const url =
313
+ documentData [ 0 ] &&
314
+ ( documentData [ 0 ] ?. SignedUrl || documentData [ 0 ] ?. URL ) ;
315
+ if ( url ) {
316
+ //convert document url in array buffer format to use embed widgets in pdf using pdf-lib
317
+ const arrayBuffer = await convertPdfArrayBuffer ( url ) ;
318
+ if ( arrayBuffer === "Error" ) {
319
+ setHandleError ( t ( "something-went-wrong-mssg" ) ) ;
320
+ } else {
321
+ setPdfArrayBuffer ( arrayBuffer ) ;
322
+ }
313
323
} else {
314
- setPdfArrayBuffer ( arrayBuffer ) ;
324
+ setHandleError ( t ( "something-went-wrong-mssg" ) ) ;
315
325
}
316
- } else {
317
- setHandleError ( t ( "something-went-wrong-mssg" ) ) ;
318
- }
319
- setIsPublicTemplate ( true ) ;
320
- const getPublicRole = documentData [ 0 ] ?. PublicRole [ 0 ] ;
321
- const getUniqueIdDetails = documentData [ 0 ] ?. Placeholders . find (
322
- ( x ) => x . Role === getPublicRole
323
- ) ;
324
- if ( getUniqueIdDetails ) {
325
- setUniqueId ( getUniqueIdDetails . Id ) ;
326
- }
327
- setSignerPos ( documentData [ 0 ] ?. Placeholders ) ;
328
- let placeholdersOrSigners = [ ] ;
329
- // const placeholder = documentData[0]?.Placeholders;
330
- for ( const placeholder of documentData [ 0 ] . Placeholders ) {
331
- //`emailExist` variable to handle condition for quick send flow and show unsigned signers list
332
- const signerIdExist = placeholder ?. signerObjId ;
333
- if ( signerIdExist ) {
334
- const getSignerData = documentData [ 0 ] . Signers . find (
335
- ( data ) => data . objectId === placeholder ?. signerObjId
336
- ) ;
337
- placeholdersOrSigners . push ( getSignerData ) ;
338
- } else {
339
- placeholdersOrSigners . push ( placeholder ) ;
326
+ setIsPublicTemplate ( true ) ;
327
+ const getPublicRole = documentData [ 0 ] ?. PublicRole [ 0 ] ;
328
+ const getUniqueIdDetails = documentData [ 0 ] ?. Placeholders . find (
329
+ ( x ) => x . Role === getPublicRole
330
+ ) ;
331
+ if ( getUniqueIdDetails ) {
332
+ setUniqueId ( getUniqueIdDetails . Id ) ;
340
333
}
334
+ setSignerPos ( documentData [ 0 ] ?. Placeholders ) ;
335
+ let placeholdersOrSigners = [ ] ;
336
+ // const placeholder = documentData[0]?.Placeholders;
337
+ for ( const placeholder of documentData [ 0 ] . Placeholders ) {
338
+ //`emailExist` variable to handle condition for quick send flow and show unsigned signers list
339
+ const signerIdExist = placeholder ?. signerObjId ;
340
+ if ( signerIdExist ) {
341
+ const getSignerData = documentData [ 0 ] . Signers . find (
342
+ ( data ) => data . objectId === placeholder ?. signerObjId
343
+ ) ;
344
+ placeholdersOrSigners . push ( getSignerData ) ;
345
+ } else {
346
+ placeholdersOrSigners . push ( placeholder ) ;
347
+ }
348
+ }
349
+ setUnSignedSigners ( placeholdersOrSigners ) ;
350
+ setPdfDetails ( documentData ) ;
351
+ setIsLoading ( {
352
+ isLoad : false
353
+ } ) ;
354
+ } else {
355
+ props ?. setTemplateStatus ( {
356
+ status : "Private"
357
+ } ) ;
341
358
}
342
- setUnSignedSigners ( placeholdersOrSigners ) ;
343
- setPdfDetails ( documentData ) ;
344
- setIsLoading ( { isLoad : false } ) ;
345
- } else if (
346
- documentData === "Error: Something went wrong!" ||
347
- ( documentData . result && documentData . result . error )
348
- ) {
349
- console . log ( "err in get template details " ) ;
350
- setHandleError ( t ( "something-went-wrong-mssg" ) ) ;
351
- setIsLoading ( { isLoad : false } ) ;
352
359
} else {
353
- setHandleError ( t ( "no-data" ) ) ;
354
- setIsLoading ( { isLoad : false } ) ;
360
+ props ?. setTemplateStatus ( {
361
+ status : "Invalid"
362
+ } ) ;
355
363
}
356
364
} catch ( err ) {
357
365
console . log ( "err in get template details " , err ) ;
0 commit comments