@@ -18,7 +18,8 @@ import {
18
18
cellsWidget ,
19
19
textWidget ,
20
20
years ,
21
- convertTextToImg
21
+ convertTextToImg ,
22
+ convertJpegToPng
22
23
} from "../../constant/Utils" ;
23
24
import CellsWidget from "./CellsWidget" ;
24
25
import DatePicker from "react-datepicker" ;
@@ -110,7 +111,6 @@ function WidgetsValueModal(props) {
110
111
const [ signature , setSignature ] = useState ( ) ;
111
112
const [ isImageSelect , setIsImageSelect ] = useState ( false ) ;
112
113
const [ isFinish , setIsFinish ] = useState ( false ) ;
113
- const [ imgWH , setImgWH ] = useState ( { } ) ;
114
114
const [ fontSelect , setFontSelect ] = useState ( fontOptions [ 0 ] . value ) ;
115
115
const [ isSavedSign , setIsSavedSign ] = useState ( false ) ;
116
116
const [ isAutoSign , setIsAutoSign ] = useState ( false ) ;
@@ -257,11 +257,11 @@ function WidgetsValueModal(props) {
257
257
setOriginalImage ( null ) ; // Reset original image when a new file is selected
258
258
setRemoveBgEnabled ( false ) ; // Optionally reset toggle
259
259
// Ensure compressedFileSize calls setImage, which then triggers the useEffect for BG removal.
260
- compressedFileSize ( file , setImgWH , setImage ) ;
260
+ compressedFileSize ( file , setImage ) ;
261
261
}
262
262
} ;
263
263
//function is used to save image,stamp widgets data
264
- const handleSaveImage = ( ) => {
264
+ const handleSaveImage = ( signatureType ) => {
265
265
const widgetsType = currWidgetsDetails ?. type ;
266
266
//`isApplyAll` is used when user edit stamp then updated signature apply all existing drawn signatures
267
267
const isApplyAll = true ;
@@ -278,10 +278,10 @@ function WidgetsValueModal(props) {
278
278
279
279
// Get updated placeholder list
280
280
const updatedPlaceholders = onSaveImage (
281
+ signatureType ,
281
282
signer . placeHolder ,
282
283
index ,
283
284
currWidgetsDetails ?. key ,
284
- imgWH ,
285
285
image ,
286
286
isAutoSign ,
287
287
widgetsType ,
@@ -299,48 +299,42 @@ function WidgetsValueModal(props) {
299
299
return object . pageNumber === pageNumber ;
300
300
} ) ;
301
301
const getImage = onSaveImage (
302
+ signatureType ,
302
303
props ?. xyPosition ,
303
304
index ,
304
305
currWidgetsDetails ?. key ,
305
- imgWH ,
306
- image
306
+ image ,
307
+ false ,
308
+ widgetsType
307
309
) ;
308
310
setXyPosition ( getImage ) ;
309
311
}
310
312
setIsAutoSign ( false ) ;
311
313
} ;
312
314
313
315
//function is used to save draw type or initial type signature
314
- const handleSaveSignature = (
315
- type ,
316
+ const handleSaveSignature = async (
317
+ signType ,
316
318
isDefaultSign ,
317
319
width ,
318
320
height ,
319
321
typedSignature
320
322
) => {
321
- //get current click widget type
323
+ // get current click widget type
322
324
const widgetsType = currWidgetsDetails ?. type ;
323
- //if there are any width and height then it will typed signature
325
+ // if there are any width and height then it will typed signature
324
326
const isTypeText = width && height ? true : false ;
325
- //final getting signature url via default select sign/default initial sign/self draw sign
326
- const signatureImg = isDefaultSign
327
+ // final getting signature url via default select sign/default initial sign/self draw sign
328
+ const signUrl = isDefaultSign
327
329
? isDefaultSign === "initials"
328
- ? myInitial
329
- : defaultSignImg
330
- : signature ;
331
-
330
+ ? await convertJpegToPng ( myInitial , "myinitials" ) // default initials set through my signature tab
331
+ : await convertJpegToPng ( defaultSignImg , "mysign" ) // default signature set through my signature tab
332
+ : signature ; // signature done by user thorugh draw, upload, typed
333
+ const signatureImg = signUrl ;
332
334
let imgWH = { width : width ? width : "" , height : height ? height : "" } ;
333
335
setIsImageSelect ( false ) ;
334
336
setImage ( ) ;
335
- //set default signature image width and height
336
- if ( isDefaultSign ) {
337
- const img = new Image ( ) ;
338
- img . src = defaultSignImg ;
339
- if ( img . complete ) {
340
- imgWH = { width : img . width , height : img . height } ;
341
- }
342
- }
343
- //`isApplyAll` is used when user edit signature/initial then updated signature apply all existing drawn signatures
337
+ // `isApplyAll` is used when user edit signature/initial then updated signature apply all existing drawn signatures
344
338
const isApplyAll = true ;
345
339
if ( uniqueId ) {
346
340
setXyPosition ( ( prevState ) =>
@@ -351,13 +345,12 @@ function WidgetsValueModal(props) {
351
345
( x ) => x . pageNumber === pageNumber
352
346
) ;
353
347
const updatedPlaceholders = onSaveSign (
354
- type ,
348
+ signType ,
355
349
signer . placeHolder ,
356
350
placeholderIndex ,
357
351
currWidgetsDetails ?. key ,
358
352
signatureImg ,
359
353
imgWH ,
360
- isDefaultSign ,
361
354
isTypeText ,
362
355
typedSignature ,
363
356
isAutoSign ,
@@ -377,13 +370,12 @@ function WidgetsValueModal(props) {
377
370
return object . pageNumber === pageNumber ;
378
371
} ) ;
379
372
const getUpdatePosition = onSaveSign (
380
- type ,
373
+ signType ,
381
374
props ?. xyPosition ,
382
375
index ,
383
376
currWidgetsDetails ?. key ,
384
377
signatureImg ,
385
378
imgWH ,
386
- isDefaultSign ,
387
379
isTypeText ,
388
380
typedSignature ,
389
381
false ,
@@ -535,7 +527,7 @@ function WidgetsValueModal(props) {
535
527
}
536
528
} ;
537
529
538
- // `handlesavesign` is used to save signaute , initials, stamp as a default
530
+ // `handlesavesign` is used to save signature , initials, stamp as a default
539
531
const handleSaveSign = async ( ) => {
540
532
if ( signature || image ?. src ) {
541
533
setIsLoader ( true ) ;
@@ -556,7 +548,7 @@ function WidgetsValueModal(props) {
556
548
objectId : User ?. id
557
549
} ;
558
550
if ( imageUrl ) {
559
- // below code is used to save or update default signaute , initials, stamp
551
+ // below code is used to save or update default signature , initials, stamp
560
552
try {
561
553
const signCls = new Parse . Object ( "contracts_Signature" ) ;
562
554
if ( props ?. saveSignCheckbox ?. signId ) {
@@ -642,13 +634,14 @@ function WidgetsValueModal(props) {
642
634
} else {
643
635
setSignature ( "" ) ;
644
636
canvasRef ?. current ?. clear ( ) ;
645
- handleSaveSignature ( isTab ) ;
637
+ const tab = isTab === "uploadImage" ? "image" : isTab ;
638
+ handleSaveSignature ( tab ) ;
646
639
}
647
640
}
648
641
setPenColor ( "blue" ) ;
649
642
} else {
650
643
setSignature ( "" ) ;
651
- handleSaveImage ( ) ;
644
+ handleSaveImage ( "image" ) ;
652
645
}
653
646
setIsImageSelect ( false ) ;
654
647
setIsDefaultSign ( false ) ;
@@ -1178,7 +1171,9 @@ function WidgetsValueModal(props) {
1178
1171
hidden
1179
1172
/>
1180
1173
< i className = "fa-light fa-cloud-upload-alt uploadImgLogo text-base-content" > </ i >
1181
- < div className = "text-[10px] text-base-content" > { t ( "upload" ) } </ div >
1174
+ < div className = "text-[10px] text-base-content" >
1175
+ { t ( "upload" ) }
1176
+ </ div >
1182
1177
</ div >
1183
1178
</ div >
1184
1179
) : (
@@ -1324,7 +1319,6 @@ function WidgetsValueModal(props) {
1324
1319
dotSize = { 1 }
1325
1320
/>
1326
1321
</ div >
1327
-
1328
1322
< div className = "flex flex-row justify-between mt-[10px]" >
1329
1323
< PenColorComponent />
1330
1324
</ div >
@@ -1988,7 +1982,7 @@ function WidgetsValueModal(props) {
1988
1982
handleClickOnNext ( isFinishDoc ) ;
1989
1983
} }
1990
1984
>
1991
- { t ( "finish " ) }
1985
+ { t ( "done " ) }
1992
1986
</ button >
1993
1987
) : (
1994
1988
< button
0 commit comments