Skip to content

Commit 4648ace

Browse files
fix : minor bug fix in template
1 parent ccdf50d commit 4648ace

File tree

5 files changed

+222
-303
lines changed

5 files changed

+222
-303
lines changed

microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js

Lines changed: 34 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,12 @@ const TemplatePlaceholder = () => {
327327

328328
//function for setting position after drop signature button over pdf
329329
const addPositionOfSignature = (item, monitor) => {
330-
getSignerPos(item, monitor);
330+
getSignerPos(item, monitor);
331331
};
332332

333333
// `getSignerPos` is used to get placeholder position when user place it and save it in array
334334
const getSignerPos = (item, monitor) => {
335-
const signer = signersdata.find((x) => x.Id === uniqueId);
335+
if(uniqueId){const signer = signersdata.find((x) => x.Id === uniqueId);
336336
if (signer) {
337337
const posZIndex = zIndex + 1;
338338
setZIndex(posZIndex);
@@ -344,8 +344,7 @@ const TemplatePlaceholder = () => {
344344
// );
345345
let filterSignerPos = signerPos.filter((data) => data.Id === uniqueId);
346346
let dropData = [];
347-
let xyPosArr = [];
348-
let xyPos = {};
347+
let placeHolder ;
349348
if (item === "onclick") {
350349
const dropObj = {
351350
xPosition: window.innerWidth / 2 - 100,
@@ -359,12 +358,11 @@ const TemplatePlaceholder = () => {
359358
zIndex: posZIndex
360359
};
361360
dropData.push(dropObj);
362-
xyPos = {
361+
placeHolder = {
363362
pageNumber: pageNumber,
364363
pos: dropData
365364
};
366365

367-
xyPosArr.push(xyPos);
368366
} else if (item.type === "BOX") {
369367
const offset = monitor.getClientOffset();
370368
//adding and updating drop position in array when user drop signature button in div
@@ -390,21 +388,14 @@ const TemplatePlaceholder = () => {
390388
};
391389

392390
dropData.push(dropObj);
393-
xyPos = {
391+
placeHolder = {
394392
pageNumber: pageNumber,
395393
pos: dropData
396394
};
397-
398-
xyPosArr.push(xyPos);
399395
}
400-
const { blockColor, Role } = signersdata.find((x) => x.Id === uniqueId);
396+
const { blockColor, Role } = signer
401397
//adding placholder in existing signer pos array (placaholder)
402398
if (filterSignerPos.length > 0) {
403-
// const colorIndex = signerPos
404-
// .map((e) => e.signerObjId)
405-
// .indexOf(signerObjId);
406-
407-
const colorIndex = signerPos.map((e) => e.Id).indexOf(uniqueId);
408399
const getPlaceHolder = filterSignerPos[0].placeHolder;
409400
const updatePlace = getPlaceHolder.filter(
410401
(data) => data.pageNumber !== pageNumber
@@ -416,79 +407,21 @@ const TemplatePlaceholder = () => {
416407
//add entry of position for same signer on multiple page
417408
if (getPageNumer.length > 0) {
418409
const getPos = getPageNumer[0].pos;
419-
const newSignPos = getPos.concat(dropData);
410+
const newSignPos = getPos.concat(dropData);
420411
let xyPos = {
421412
pageNumber: pageNumber,
422413
pos: newSignPos
423414
};
424415
updatePlace.push(xyPos);
425-
let placeHolderPos;
426-
if (contractName) {
427-
placeHolderPos = {
428-
blockColor: blockColor ? blockColor : color[isSelectListId],
429-
signerObjId: signerObjId,
430-
placeHolder: updatePlace,
431-
signerPtr: {
432-
__type: "Pointer",
433-
className: `${contractName}`,
434-
objectId: signerObjId
435-
},
436-
Role: Role ? Role : roleName,
437-
Id: uniqueId
438-
};
439-
} else {
440-
placeHolderPos = {
441-
blockColor: blockColor ? blockColor : color[isSelectListId],
442-
signerObjId: "",
443-
placeHolder: updatePlace,
444-
signerPtr: {},
445-
Role: Role ? Role : roleName,
446-
Id: uniqueId
447-
};
448-
}
449-
// signerPos.splice(colorIndex, 1, placeHolderPos);
450-
const newArry = [placeHolderPos];
451-
const newArray = [
452-
...signerPos.slice(0, colorIndex),
453-
...newArry,
454-
...signerPos.slice(colorIndex + 1)
455-
];
456-
setSignerPos(newArray);
416+
const updatesignerPos = signerPos.map((x) =>
417+
x.Id === uniqueId ? { ...x, placeHolder: updatePlace } : x
418+
);
419+
setSignerPos(updatesignerPos);
457420
} else {
458-
const newSignPoss = getPlaceHolder.concat(xyPosArr[0]);
459-
let placeHolderPos;
460-
if (contractName) {
461-
placeHolderPos = {
462-
blockColor: color[isSelectListId],
463-
signerObjId: signerObjId,
464-
placeHolder: newSignPoss,
465-
signerPtr: {
466-
__type: "Pointer",
467-
className: `${contractName}`,
468-
objectId: signerObjId
469-
},
470-
Role: Role ? Role : roleName,
471-
Id: uniqueId
472-
};
473-
} else {
474-
placeHolderPos = {
475-
blockColor: color[isSelectListId],
476-
signerObjId: "",
477-
placeHolder: newSignPoss,
478-
signerPtr: {},
479-
Role: Role ? Role : roleName,
480-
Id: uniqueId
481-
};
482-
}
483-
484-
const newArry = [placeHolderPos];
485-
const newArray = [
486-
...signerPos.slice(0, colorIndex),
487-
...newArry,
488-
...signerPos.slice(colorIndex + 1)
489-
];
490-
491-
setSignerPos(newArray);
421+
const updatesignerPos = signerPos.map((x) =>
422+
x.Id === uniqueId ? { ...x, placeHolder: [...x.placeHolder, placeHolder] } : x
423+
);
424+
setSignerPos(updatesignerPos);
492425
}
493426
} else {
494427
//adding new placeholder for selected signer in pos array (placeholder)
@@ -502,7 +435,7 @@ const TemplatePlaceholder = () => {
502435
},
503436
signerObjId: signerObjId,
504437
blockColor: blockColor ? blockColor : color[isSelectListId],
505-
placeHolder: xyPosArr,
438+
placeHolder: [placeHolder],
506439
Role: Role ? Role : roleName,
507440
Id: uniqueId
508441
};
@@ -511,18 +444,17 @@ const TemplatePlaceholder = () => {
511444
signerPtr: {},
512445
signerObjId: "",
513446
blockColor: blockColor ? blockColor : color[isSelectListId],
514-
placeHolder: xyPosArr,
447+
placeHolder: [placeHolder],
515448
Role: Role ? Role : roleName,
516449
Id: uniqueId
517450
};
518451
}
519-
520452
setSignerPos((prev) => [...prev, placeHolderPos]);
521453
}
522454
setIsMailSend(false);
523455
} else {
524456
setIsReceipent(false);
525-
}
457+
}}
526458
};
527459
//function for get pdf page details
528460
const pageDetails = async (pdf) => {
@@ -884,18 +816,18 @@ const TemplatePlaceholder = () => {
884816
// `handleDeleteUser` function is used to delete record and placeholder when user click on delete which is place next user name in recipients list
885817
const handleDeleteUser = (Id) => {
886818
const updateSigner = signersdata
887-
.filter((x) => x.Id !== Id)
888-
.map((x, i) => ({ ...x, blockColor: color[i] }));
819+
.filter((x) => x.Id !== Id)
820+
.map((x, i) => ({ ...x, blockColor: color[i] }));
889821
setSignersData(updateSigner);
890822
const updatePlaceholderUser = signerPos
891-
.filter((x) => x.Id !== Id)
892-
.map((x, i) => ({ ...x, blockColor: color[i] }));
893-
const index = signersdata.findIndex((x)=> x.Id === Id)
894-
if(index === signersdata.length - 1){
895-
setUniqueId(updateSigner[updateSigner.length - 1]?.Id ||"");
823+
.filter((x) => x.Id !== Id)
824+
.map((x, i) => ({ ...x, blockColor: color[i] }));
825+
const index = signersdata.findIndex((x) => x.Id === Id);
826+
if (index === signersdata.length - 1) {
827+
setUniqueId(updateSigner[updateSigner.length - 1]?.Id || "");
896828
setIsSelectId(0);
897-
}else{
898-
setUniqueId(updateSigner[index]?.Id ||"");
829+
} else {
830+
setUniqueId(updateSigner[index]?.Id || "");
899831
setIsSelectId(index);
900832
}
901833

@@ -924,12 +856,14 @@ const TemplatePlaceholder = () => {
924856

925857
const updateSigner = signersdata.map((x) => {
926858
if (x.Id === uniqueId) {
927-
return { ...x, ...data };
859+
return { ...x, ...data, className: "contracts_Contactbook" };
928860
}
929861
return { ...x };
930862
});
931863
setSignersData(updateSigner);
932864
setIsMailSend(false);
865+
const index = signersdata.findIndex((x)=> x.Id ===uniqueId)
866+
setIsSelectId(index)
933867
};
934868

935869
// `closePopup` is used to close Add/Choose signer modal
@@ -1054,7 +988,10 @@ const TemplatePlaceholder = () => {
1054988
handleClose={() => setIsCreateDocModal(false)}
1055989
>
1056990
<div style={{ height: "100%", padding: 20 }}>
1057-
<p>Do you want to create a document using the template you just created ?</p>
991+
<p>
992+
Do you want to create a document using the template you just
993+
created ?
994+
</p>
1058995
<div
1059996
style={{
1060997
height: "1px",

microfrontends/SignDocuments/src/Component/component/fieldsComponent.js

Lines changed: 77 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,56 @@ function FieldsComponent({
8383
justifyContent: "center"
8484
}}
8585
onClick={() => {
86-
if (signersdata?.length) {
87-
handleModal();
88-
}
86+
// if (signersdata?.length) {
87+
handleModal();
88+
// }
8989
}}
9090
>
91-
<span style={{ fontSize: "13px", fontWeight: "700" }}>
91+
<span
92+
style={{
93+
fontSize: "13px",
94+
fontWeight: "700",
95+
textAlign: "center"
96+
}}
97+
>
9298
Recipient
9399
</span>
94-
<span style={{ fontSize: "13px", fontWeight: "700" }}>
100+
<span
101+
style={{
102+
fontSize: "13px",
103+
fontWeight: "700",
104+
display: "flex",
105+
alignItems: "center"
106+
}}
107+
>
95108
{signersdata[isSelectListId]?.Role && (
96109
<div>
97-
{signersdata[isSelectListId]?.Name
98-
? ` : ${signersdata[isSelectListId]?.Name}`
99-
: ` : ${signersdata[isSelectListId]?.Role}`}
110+
{signersdata[isSelectListId]?.Name ? (
111+
<>
112+
:{" "}
113+
{signersdata[isSelectListId]?.Name?.length > 12
114+
? `${signersdata[isSelectListId].Name.slice(
115+
0,
116+
12
117+
)}...`
118+
: signersdata[isSelectListId]?.Name}
119+
</>
120+
) : (
121+
<>
122+
:{" "}
123+
{signersdata[isSelectListId]?.Role?.length > 12
124+
? `${signersdata[isSelectListId].Role.slice(
125+
0,
126+
12
127+
)}...`
128+
: signersdata[isSelectListId]?.Role}
129+
</>
130+
)}
100131
</div>
101132
)}
133+
<div style={{ marginLeft: 6, fontSize: 16 }}>
134+
<i className="fa-solid fa-angle-down"></i>
135+
</div>
102136
</span>
103137
</div>
104138
)}
@@ -333,25 +367,41 @@ function FieldsComponent({
333367
</div>
334368
</div>
335369
)}
336-
<ModalUi
337-
title={"Recipients"}
338-
isOpen={isSignersModal}
339-
handleClose={handleModal}
340-
>
341-
<RecipientList
342-
signerPos={signerPos}
343-
signersdata={signersdata}
344-
isSelectListId={isSelectListId}
345-
setSignerObjId={setSignerObjId}
346-
setIsSelectId={setIsSelectId}
347-
setContractName={setContractName}
348-
setUniqueId={setUniqueId}
349-
setRoleName={setRoleName}
350-
handleDeleteUser={handleDeleteUser}
351-
handleRoleChange={handleRoleChange}
352-
handleOnBlur={handleOnBlur}
353-
/>
354-
</ModalUi>
370+
{isSignersModal && (
371+
<ModalUi
372+
title={"Recipients"}
373+
isOpen={isSignersModal}
374+
handleClose={handleModal}
375+
>
376+
{signersdata.length > 0 ? (
377+
<RecipientList
378+
signerPos={signerPos}
379+
signersdata={signersdata}
380+
isSelectListId={isSelectListId}
381+
setSignerObjId={setSignerObjId}
382+
setIsSelectId={setIsSelectId}
383+
setContractName={setContractName}
384+
setUniqueId={setUniqueId}
385+
setRoleName={setRoleName}
386+
handleDeleteUser={handleDeleteUser}
387+
handleRoleChange={handleRoleChange}
388+
handleOnBlur={handleOnBlur}
389+
handleModal={handleModal}
390+
/>
391+
) : (
392+
<div
393+
style={{
394+
padding: 20,
395+
fontSize: 15,
396+
fontWeight: "500",
397+
textAlign: "center"
398+
}}
399+
>
400+
Please add Recipient
401+
</div>
402+
)}
403+
</ModalUi>
404+
)}
355405
</>
356406
);
357407
}

microfrontends/SignDocuments/src/Component/component/renderPdf.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,14 +381,12 @@ function RenderPdf({
381381
};
382382
const handleUserName = (signerId, Role) => {
383383
if (signerId) {
384-
const checkSign = signersdata.filter(
385-
(sign) => sign.objectId === signerId
386-
);
387-
if (checkSign.length > 0) {
384+
const checkSign = signersdata.find((sign) => sign.objectId === signerId);
385+
if (checkSign?.Name) {
388386
return (
389387
<>
390388
<div style={{ color: "black", fontSize: 11 }}>
391-
{checkSign[0].Name}
389+
{checkSign?.Name}
392390
</div>
393391
<div style={{ color: "black", fontSize: 11 }}> {`(${Role})`} </div>
394392
</>
@@ -788,7 +786,6 @@ function RenderPdf({
788786
xyPostion,
789787
index,
790788
setXyPostion
791-
792789
);
793790
}}
794791
>

0 commit comments

Comments
 (0)