@@ -24,7 +24,8 @@ import {
24
24
radioButtonWidget ,
25
25
replaceMailVaribles ,
26
26
fetchSubscription ,
27
- convertPdfArrayBuffer
27
+ convertPdfArrayBuffer ,
28
+ contractUsers
28
29
} from "../constant/Utils" ;
29
30
import Loader from "../primitives/LoaderWithMsg" ;
30
31
import HandleError from "../primitives/HandleError" ;
@@ -138,10 +139,12 @@ function PdfRequestFiles() {
138
139
// eslint-disable-next-line react-hooks/exhaustive-deps
139
140
} , [ divRef . current ] ) ;
140
141
141
- async function checkIsSubscribed ( extUserId ) {
142
- const res = await fetchSubscription ( extUserId ) ;
142
+ async function checkIsSubscribed ( extUserId , contactId ) {
143
+ const isGuestSign = localStorage . getItem ( "isGuestSigner" ) ;
144
+ const res = await fetchSubscription ( extUserId , contactId ) ;
143
145
const plan = res . plan ;
144
- const billingDate = res . billingDate ;
146
+ const billingDate = res ?. billingDate ;
147
+ const status = res ?. status ;
145
148
if ( plan === "freeplan" ) {
146
149
return true ;
147
150
} else if ( billingDate ) {
@@ -155,8 +158,15 @@ function PdfRequestFiles() {
155
158
navigate ( `/subscription` ) ;
156
159
}
157
160
}
161
+ } else if ( isGuestSign ) {
162
+ if ( status ) {
163
+ setIsSubscribed ( true ) ;
164
+ return true ;
165
+ } else {
166
+ setIsSubscriptionExpired ( true ) ;
167
+ }
158
168
} else {
159
- if ( location . pathname . includes ( "/load/" ) ) {
169
+ if ( isGuestSign ) {
160
170
setIsSubscriptionExpired ( true ) ;
161
171
} else {
162
172
navigate ( `/subscription` ) ;
@@ -178,9 +188,7 @@ function PdfRequestFiles() {
178
188
} else {
179
189
setPdfArrayBuffer ( arrayBuffer ) ;
180
190
}
181
- if ( isEnableSubscription ) {
182
- await checkIsSubscribed ( documentData [ 0 ] ?. ExtUserPtr ?. objectId ) ;
183
- }
191
+
184
192
setExtUserId ( documentData [ 0 ] ?. ExtUserPtr ?. objectId ) ;
185
193
const isCompleted =
186
194
documentData [ 0 ] . IsCompleted && documentData [ 0 ] . IsCompleted ;
@@ -196,6 +204,12 @@ function PdfRequestFiles() {
196
204
) ;
197
205
198
206
currUserId = getCurrentSigner [ 0 ] ? getCurrentSigner [ 0 ] . objectId : "" ;
207
+ if ( isEnableSubscription ) {
208
+ await checkIsSubscribed (
209
+ documentData [ 0 ] ?. ExtUserPtr ?. objectId ,
210
+ currUserId
211
+ ) ;
212
+ }
199
213
setSignerObjectId ( currUserId ) ;
200
214
if ( documentData [ 0 ] . SignedUrl ) {
201
215
setPdfUrl ( documentData [ 0 ] . SignedUrl ) ;
@@ -577,6 +591,20 @@ function PdfRequestFiles() {
577
591
) ;
578
592
//get ExistUserPtr object id of user class to get tenantDetails
579
593
const objectId = pdfDetails ?. [ 0 ] ?. ExtUserPtr ?. UserId ?. objectId ;
594
+
595
+ const res = await contractUsers ( jsonSender ?. email ) ;
596
+ console . log ( "res" , res ) ;
597
+ let activeMailAdapter = "" ;
598
+ if ( res === "Error: Something went wrong!" ) {
599
+ setHandleError ( "Error: Something went wrong!" ) ;
600
+ setIsLoading ( {
601
+ isLoad : false
602
+ } ) ;
603
+ } else if ( ! res || res ?. length === 0 ) {
604
+ activeMailAdapter = "" ;
605
+ } else if ( res [ 0 ] && res . length ) {
606
+ activeMailAdapter = res [ 0 ] ?. active_mail_adapter ;
607
+ }
580
608
//function for call to embed signature in pdf and get digital signature pdf
581
609
try {
582
610
const res = await signPdfFun (
@@ -585,7 +613,8 @@ function PdfRequestFiles() {
585
613
signerObjectId ,
586
614
setIsAlert ,
587
615
objectId ,
588
- isSubscribed
616
+ isSubscribed ,
617
+ activeMailAdapter
589
618
) ;
590
619
if ( res && res . status === "success" ) {
591
620
setPdfUrl ( res . data ) ;
@@ -677,6 +706,7 @@ function PdfRequestFiles() {
677
706
}
678
707
679
708
let params = {
709
+ mailProvider : activeMailAdapter ,
680
710
extUserId : extUserId ,
681
711
recipient : user . Email ,
682
712
subject : requestSubject
0 commit comments