@@ -18,7 +18,8 @@ import {
1818 cellsWidget ,
1919 textWidget ,
2020 years ,
21- convertTextToImg
21+ convertTextToImg ,
22+ convertJpegToPng
2223} from "../../constant/Utils" ;
2324import CellsWidget from "./CellsWidget" ;
2425import DatePicker from "react-datepicker" ;
@@ -110,7 +111,6 @@ function WidgetsValueModal(props) {
110111 const [ signature , setSignature ] = useState ( ) ;
111112 const [ isImageSelect , setIsImageSelect ] = useState ( false ) ;
112113 const [ isFinish , setIsFinish ] = useState ( false ) ;
113- const [ imgWH , setImgWH ] = useState ( { } ) ;
114114 const [ fontSelect , setFontSelect ] = useState ( fontOptions [ 0 ] . value ) ;
115115 const [ isSavedSign , setIsSavedSign ] = useState ( false ) ;
116116 const [ isAutoSign , setIsAutoSign ] = useState ( false ) ;
@@ -257,11 +257,11 @@ function WidgetsValueModal(props) {
257257 setOriginalImage ( null ) ; // Reset original image when a new file is selected
258258 setRemoveBgEnabled ( false ) ; // Optionally reset toggle
259259 // Ensure compressedFileSize calls setImage, which then triggers the useEffect for BG removal.
260- compressedFileSize ( file , setImgWH , setImage ) ;
260+ compressedFileSize ( file , setImage ) ;
261261 }
262262 } ;
263263 //function is used to save image,stamp widgets data
264- const handleSaveImage = ( ) => {
264+ const handleSaveImage = ( signatureType ) => {
265265 const widgetsType = currWidgetsDetails ?. type ;
266266 //`isApplyAll` is used when user edit stamp then updated signature apply all existing drawn signatures
267267 const isApplyAll = true ;
@@ -278,10 +278,10 @@ function WidgetsValueModal(props) {
278278
279279 // Get updated placeholder list
280280 const updatedPlaceholders = onSaveImage (
281+ signatureType ,
281282 signer . placeHolder ,
282283 index ,
283284 currWidgetsDetails ?. key ,
284- imgWH ,
285285 image ,
286286 isAutoSign ,
287287 widgetsType ,
@@ -299,48 +299,42 @@ function WidgetsValueModal(props) {
299299 return object . pageNumber === pageNumber ;
300300 } ) ;
301301 const getImage = onSaveImage (
302+ signatureType ,
302303 props ?. xyPosition ,
303304 index ,
304305 currWidgetsDetails ?. key ,
305- imgWH ,
306- image
306+ image ,
307+ false ,
308+ widgetsType
307309 ) ;
308310 setXyPosition ( getImage ) ;
309311 }
310312 setIsAutoSign ( false ) ;
311313 } ;
312314
313315 //function is used to save draw type or initial type signature
314- const handleSaveSignature = (
315- type ,
316+ const handleSaveSignature = async (
317+ signType ,
316318 isDefaultSign ,
317319 width ,
318320 height ,
319321 typedSignature
320322 ) => {
321- //get current click widget type
323+ // get current click widget type
322324 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
324326 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
327329 ? 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 ;
332334 let imgWH = { width : width ? width : "" , height : height ? height : "" } ;
333335 setIsImageSelect ( false ) ;
334336 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
344338 const isApplyAll = true ;
345339 if ( uniqueId ) {
346340 setXyPosition ( ( prevState ) =>
@@ -351,13 +345,12 @@ function WidgetsValueModal(props) {
351345 ( x ) => x . pageNumber === pageNumber
352346 ) ;
353347 const updatedPlaceholders = onSaveSign (
354- type ,
348+ signType ,
355349 signer . placeHolder ,
356350 placeholderIndex ,
357351 currWidgetsDetails ?. key ,
358352 signatureImg ,
359353 imgWH ,
360- isDefaultSign ,
361354 isTypeText ,
362355 typedSignature ,
363356 isAutoSign ,
@@ -377,13 +370,12 @@ function WidgetsValueModal(props) {
377370 return object . pageNumber === pageNumber ;
378371 } ) ;
379372 const getUpdatePosition = onSaveSign (
380- type ,
373+ signType ,
381374 props ?. xyPosition ,
382375 index ,
383376 currWidgetsDetails ?. key ,
384377 signatureImg ,
385378 imgWH ,
386- isDefaultSign ,
387379 isTypeText ,
388380 typedSignature ,
389381 false ,
@@ -535,7 +527,7 @@ function WidgetsValueModal(props) {
535527 }
536528 } ;
537529
538- // `handlesavesign` is used to save signaute , initials, stamp as a default
530+ // `handlesavesign` is used to save signature , initials, stamp as a default
539531 const handleSaveSign = async ( ) => {
540532 if ( signature || image ?. src ) {
541533 setIsLoader ( true ) ;
@@ -556,7 +548,7 @@ function WidgetsValueModal(props) {
556548 objectId : User ?. id
557549 } ;
558550 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
560552 try {
561553 const signCls = new Parse . Object ( "contracts_Signature" ) ;
562554 if ( props ?. saveSignCheckbox ?. signId ) {
@@ -642,13 +634,14 @@ function WidgetsValueModal(props) {
642634 } else {
643635 setSignature ( "" ) ;
644636 canvasRef ?. current ?. clear ( ) ;
645- handleSaveSignature ( isTab ) ;
637+ const tab = isTab === "uploadImage" ? "image" : isTab ;
638+ handleSaveSignature ( tab ) ;
646639 }
647640 }
648641 setPenColor ( "blue" ) ;
649642 } else {
650643 setSignature ( "" ) ;
651- handleSaveImage ( ) ;
644+ handleSaveImage ( "image" ) ;
652645 }
653646 setIsImageSelect ( false ) ;
654647 setIsDefaultSign ( false ) ;
@@ -1178,7 +1171,9 @@ function WidgetsValueModal(props) {
11781171 hidden
11791172 />
11801173 < 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 >
11821177 </ div >
11831178 </ div >
11841179 ) : (
@@ -1324,7 +1319,6 @@ function WidgetsValueModal(props) {
13241319 dotSize = { 1 }
13251320 />
13261321 </ div >
1327-
13281322 < div className = "flex flex-row justify-between mt-[10px]" >
13291323 < PenColorComponent />
13301324 </ div >
@@ -1988,7 +1982,7 @@ function WidgetsValueModal(props) {
19881982 handleClickOnNext ( isFinishDoc ) ;
19891983 } }
19901984 >
1991- { t ( "finish " ) }
1985+ { t ( "done " ) }
19921986 </ button >
19931987 ) : (
19941988 < button
0 commit comments