@@ -27,13 +27,13 @@ function Header({
27
27
signersdata,
28
28
isMailSend,
29
29
alertSendEmail,
30
- isSigned,
31
30
isCompleted,
32
31
isShowHeader,
33
32
decline,
34
33
currentSigner,
35
34
dataTut4,
36
- alreadySign
35
+ alreadySign,
36
+ isSignYourself
37
37
} ) {
38
38
const isMobile = window . innerWidth < 767 ;
39
39
const navigate = useNavigate ( ) ;
@@ -61,12 +61,19 @@ function Header({
61
61
62
62
const pdf = await getBase64FromUrl ( pdfUrl ) ;
63
63
const isAndroidDevice = navigator . userAgent . match ( / A n d r o i d / i) ;
64
- const isAppleDevice = ( / i P a d | i P h o n e | i P o d / . test ( navigator . platform ) || ( navigator . platform === 'MacIntel' && navigator . maxTouchPoints > 1 ) ) && ! window . MSStream
64
+ const isAppleDevice =
65
+ ( / i P a d | i P h o n e | i P o d / . test ( navigator . platform ) ||
66
+ ( navigator . platform === "MacIntel" && navigator . maxTouchPoints > 1 ) ) &&
67
+ ! window . MSStream ;
65
68
if ( isAndroidDevice || isAppleDevice ) {
66
- const byteArray = Uint8Array . from ( atob ( pdf ) . split ( '' ) . map ( char => char . charCodeAt ( 0 ) ) ) ;
67
- const blob = new Blob ( [ byteArray ] , { type : 'application/pdf' } ) ;
69
+ const byteArray = Uint8Array . from (
70
+ atob ( pdf )
71
+ . split ( "" )
72
+ . map ( ( char ) => char . charCodeAt ( 0 ) )
73
+ ) ;
74
+ const blob = new Blob ( [ byteArray ] , { type : "application/pdf" } ) ;
68
75
const blobUrl = URL . createObjectURL ( blob ) ;
69
- window . open ( blobUrl , ' _blank' ) ;
76
+ window . open ( blobUrl , " _blank" ) ;
70
77
} else {
71
78
printModule ( { printable : pdf , type : "pdf" , base64 : true } ) ;
72
79
}
@@ -75,27 +82,86 @@ function Header({
75
82
//handle download signed pdf
76
83
const handleDownloadPdf = ( ) => {
77
84
const pdfName = pdfDetails [ 0 ] && pdfDetails [ 0 ] . Name ;
78
-
79
- saveAs ( pdfUrl , `${ sanitizeFileName ( pdfName ) } _signed_by_OpenSign™.pdf` ) ;
85
+ saveAs ( pdfUrl , `${ sanitizeFileName ( pdfName ) } _signed_by_OpenSign™.pdf` ) ;
80
86
} ;
81
-
87
+
82
88
const sanitizeFileName = ( pdfName ) => {
83
89
// Replace spaces with underscore
84
90
return pdfName . replace ( / / g, '_' ) ;
85
91
}
86
-
87
-
92
+ //certificate generate and download component in mobile view
93
+ const CertificateDropDown = ( ) => {
94
+ //after generate download certifcate pdf
95
+ const handleDownload = ( pdfBlob , fileName ) => {
96
+ if ( pdfBlob ) {
97
+ const url = window . URL . createObjectURL ( pdfBlob ) ;
98
+ // Create a temporary anchor element
99
+ const link = document . createElement ( "a" ) ;
100
+ link . href = url ;
101
+ link . download = fileName ;
102
+ // Append the anchor to the body
103
+ document . body . appendChild ( link ) ;
104
+ // Programmatically click the anchor to trigger the download
105
+ link . click ( ) ;
106
+ // Remove the anchor from the body
107
+ document . body . removeChild ( link ) ;
108
+ // Release the object URL to free up resources
109
+ window . URL . revokeObjectURL ( url ) ;
110
+ }
111
+ } ;
112
+ return (
113
+ < PDFDownloadLink
114
+ onClick = { ( e ) => e . preventDefault ( ) }
115
+ style = { { textDecoration : "none" , zIndex : "35" } }
116
+ document = { < Certificate pdfData = { pdfDetails } /> }
117
+ >
118
+ { ( { blob, url, loading, error } ) => (
119
+ < >
120
+ { loading ? (
121
+ "Loading document..."
122
+ ) : (
123
+ < div
124
+ style = { {
125
+ border : "none" ,
126
+ backgroundColor : "#fff"
127
+ } }
128
+ onClick = { ( ) =>
129
+ handleDownload (
130
+ blob ,
131
+ `completion certificate-${
132
+ pdfDetails [ 0 ] && pdfDetails [ 0 ] . Name
133
+ } .pdf`
134
+ )
135
+ }
136
+ >
137
+ < i
138
+ className = "fa fa-certificate"
139
+ style = { {
140
+ marginRight : "2px"
141
+ } }
142
+ aria-hidden = "true"
143
+ > </ i >
144
+ Certificate
145
+ </ div >
146
+ ) }
147
+ </ >
148
+ ) }
149
+ </ PDFDownloadLink >
150
+ ) ;
151
+ } ;
88
152
return (
89
153
< div
90
- style = { { padding : ! isGuestSigner && "5px 0px 5px 0px" } }
154
+ style = { { padding : ! isGuestSigner && "5px 0px 5px 0px" } }
91
155
className = "mobileHead"
92
156
>
93
157
{ isMobile && isShowHeader ? (
94
158
< div
95
159
id = "navbar"
96
160
className = { isGuestSigner ? "stickySignerHead" : "stickyHead" }
97
161
style = { {
98
- width : isGuestSigner ? window . innerWidth : window . innerWidth - 30 + "px"
162
+ width : isGuestSigner
163
+ ? window . innerWidth
164
+ : window . innerWidth - 30 + "px"
99
165
} }
100
166
>
101
167
< div className = "preBtn2" >
@@ -140,16 +206,16 @@ function Header({
140
206
style = { { color : "gray" , cursor : "pointer" } }
141
207
> </ i >
142
208
</ div >
143
- { pdfUrl ? (
209
+ { pdfUrl && alreadySign ? (
144
210
< DropdownMenu . Root >
145
211
< DropdownMenu . Trigger asChild >
146
212
< div
147
- // onClick={() => handleDownloadPdf()}
148
213
style = { {
149
214
color : themeColor ( ) ,
150
215
border : "none" ,
151
216
fontWeight : "650" ,
152
- fontSize : "16px"
217
+ fontSize : "16px" ,
218
+ padding :"0px 3px 0px 5px"
153
219
} }
154
220
>
155
221
< i className = "fa fa-ellipsis-v" aria-hidden = "true" > </ i >
@@ -179,51 +245,46 @@ function Header({
179
245
Download
180
246
</ div >
181
247
</ DropdownMenu . Item >
182
- < DropdownMenu . Item className = "DropdownMenuItem" >
183
- < PDFDownloadLink
184
- style = { { textDecoration : "none" } }
185
- document = { < Certificate pdfData = { pdfDetails } /> }
186
- fileName = { `completion certificate-${
187
- pdfDetails [ 0 ] && pdfDetails [ 0 ] . Name
188
- } .pdf`}
248
+ { recipient && pdfDetails [ 0 ] && pdfDetails . length > 0 ? (
249
+ < DropdownMenu . Item className = "DropdownMenuItem" >
250
+ < CertificateDropDown />
251
+ </ DropdownMenu . Item >
252
+ ) : isPdfRequestFiles &&
253
+ alreadySign &&
254
+ isCompleted . isCertificate ? (
255
+ < DropdownMenu . Item className = "DropdownMenuItem" >
256
+ < CertificateDropDown />
257
+ </ DropdownMenu . Item >
258
+ ) :isSignYourself && (
259
+ < DropdownMenu . Item className = "DropdownMenuItem" >
260
+ < CertificateDropDown />
261
+ </ DropdownMenu . Item >
262
+ ) }
263
+ < DropdownMenu . Item
264
+ className = "DropdownMenuItem"
265
+ onClick = { handleToPrint }
266
+ >
267
+ < div
268
+ style = { {
269
+ display : "flex" ,
270
+ flexDirection : "row"
271
+ } }
189
272
>
190
- { ( { blob, url, loading, error } ) => (
191
- < >
192
- { console . log ( "error" , error ) }
193
- { loading ? (
194
- "Loading document..."
195
- ) : (
196
- < button
197
- type = "button"
198
- className = "defaultBtn certificateBtn"
199
- style = { {
200
- display : "flex" ,
201
- flexDirection : "row" ,
202
- alignItems : "center"
203
- } }
204
- >
205
- < i
206
- className = "fa fa-certificate"
207
- style = { {
208
- color : "white" ,
209
- fontSize : "15px" ,
210
- marginRight : "3px"
211
- } }
212
- aria-hidden = "true"
213
- > </ i >
214
- Certificate
215
- </ button >
216
- ) }
217
- </ >
218
- ) }
219
- </ PDFDownloadLink >
273
+ { " " }
274
+ < i
275
+ className = "fa fa-print"
276
+ aria-hidden = "true"
277
+ style = { { marginRight : "2px" } }
278
+ > </ i >
279
+ Print
280
+ </ div >
220
281
</ DropdownMenu . Item >
221
282
</ DropdownMenu . Content >
222
283
</ DropdownMenu . Portal >
223
284
</ DropdownMenu . Root >
224
285
) : (
225
286
< div style = { { display : "flex" , justifyContent : "space-around" } } >
226
- { /* current signer is checking user send request and check status of pdf sign than if current
287
+ { /* current signer is checking user send request and check status of pdf sign than if current
227
288
user exist than show finish button else no
228
289
*/ }
229
290
{ currentSigner && (
@@ -267,6 +328,8 @@ function Header({
267
328
onClick = { ( ) => {
268
329
if ( ! pdfUrl ) {
269
330
embedImages ( ) ;
331
+ } else if ( isPdfRequestFiles ) {
332
+ embedImages ( ) ;
270
333
}
271
334
} }
272
335
style = { {
@@ -689,4 +752,4 @@ function Header({
689
752
) ;
690
753
}
691
754
692
- export default Header ;
755
+ export default Header ;
0 commit comments