Skip to content

Commit c5762a0

Browse files
Merge pull request #293 from OpenSignLabs/feat_template
fix: minor bug fix in template component
2 parents 1cca5a3 + dc40b04 commit c5762a0

File tree

7 files changed

+121
-88
lines changed

7 files changed

+121
-88
lines changed

microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js

Lines changed: 70 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ const TemplatePlaceholder = () => {
341341
// `getSignerPos` is used to get placeholder position when user place it and save it in array
342342
const getSignerPos = (item, monitor) => {
343343
const singer = signersdata.find((x) => x.Id === uniqueId);
344-
345344
if (singer) {
346345
const posZIndex = zIndex + 1;
347346
setZIndex(posZIndex);
@@ -710,67 +709,72 @@ const TemplatePlaceholder = () => {
710709
}
711710
};
712711
const handleSaveTemplate = async () => {
713-
const loadObj = {
714-
isLoad: true,
715-
message: "This might take some time"
716-
};
717-
setIsLoading(loadObj);
718-
setIsSendAlert(false);
719-
let signers = [];
720-
if (signersdata?.length > 0) {
721-
signersdata.forEach((x) => {
722-
if (x.objectId) {
723-
const obj = {
724-
__type: "Pointer",
725-
className: "contracts_Contactbook",
726-
objectId: x.objectId
727-
};
728-
signers.push(obj);
729-
}
730-
});
731-
}
732-
try {
733-
const data = {
734-
Placeholders: signerPos,
735-
SignedUrl: pdfDetails[0].URL,
736-
Signers: signers
712+
const singer = signersdata.find((x) => x.Id === uniqueId);
713+
if (singer) {
714+
const loadObj = {
715+
isLoad: true,
716+
message: "This might take some time"
737717
};
738-
739-
await axios
740-
.put(
741-
`${localStorage.getItem("baseUrl")}classes/${localStorage.getItem(
742-
"_appName"
743-
)}_Template/${templateId}`,
744-
data,
745-
{
746-
headers: {
747-
"Content-Type": "application/json",
748-
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
749-
"X-Parse-Session-Token": localStorage.getItem("accesstoken")
750-
}
718+
setIsLoading(loadObj);
719+
setIsSendAlert(false);
720+
let signers = [];
721+
if (signersdata?.length > 0) {
722+
signersdata.forEach((x) => {
723+
if (x.objectId) {
724+
const obj = {
725+
__type: "Pointer",
726+
className: "contracts_Contactbook",
727+
objectId: x.objectId
728+
};
729+
signers.push(obj);
751730
}
752-
)
753-
.then((result) => {
754-
setIsCreateDocModal(true);
755-
setIsMailSend(true);
756-
const loadObj = {
757-
isLoad: false
758-
};
759-
setIsLoading(loadObj);
760-
})
761-
.catch((err) => {
762-
console.log("axois err ", err);
763731
});
764-
} catch (e) {
765-
console.log("error", e);
732+
}
733+
try {
734+
const data = {
735+
Placeholders: signerPos,
736+
SignedUrl: pdfDetails[0].URL,
737+
Signers: signers
738+
};
739+
740+
await axios
741+
.put(
742+
`${localStorage.getItem("baseUrl")}classes/${localStorage.getItem(
743+
"_appName"
744+
)}_Template/${templateId}`,
745+
data,
746+
{
747+
headers: {
748+
"Content-Type": "application/json",
749+
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
750+
"X-Parse-Session-Token": localStorage.getItem("accesstoken")
751+
}
752+
}
753+
)
754+
.then((result) => {
755+
setIsCreateDocModal(true);
756+
setIsMailSend(true);
757+
const loadObj = {
758+
isLoad: false
759+
};
760+
setIsLoading(loadObj);
761+
})
762+
.catch((err) => {
763+
console.log("axois err ", err);
764+
});
765+
} catch (e) {
766+
console.log("error", e);
767+
}
768+
} else {
769+
setIsReceipent(false);
766770
}
767771
};
768772
//here you can add your messages in content and selector is key of particular steps
769773

770774
const tourConfig = [
771775
{
772776
selector: '[data-tut="reactourAddbtn"]',
773-
content: `Clicking "Add" button will show you popup of Add Role, fill role name or it will take by default name and create new receipent.`,
777+
content: `Clicking "Add role" button will allow you to add various signer roles. You can attach users to each role in subsequent steps.`,
774778
position: "top",
775779
observe: '[data-tut="reactourAddbtn--observe"]',
776780
style: { fontSize: "13px" }
@@ -873,7 +877,7 @@ const TemplatePlaceholder = () => {
873877
e.preventDefault();
874878
const count = signersdata.length > 0 ? signersdata.length + 1 : 1;
875879
const Id = randomId();
876-
const index = signersdata?.length || 0;
880+
const index = signersdata.length;
877881
const obj = {
878882
Role: roleName || "User " + count,
879883
Id: Id,
@@ -889,13 +893,19 @@ const TemplatePlaceholder = () => {
889893
// `handleDeleteUser` function is used to delete record and placeholder when user click on delete which is place next user name in recipients list
890894
const handleDeleteUser = (Id) => {
891895
const updateSigner = signersdata
892-
.filter((x) => x.Id !== Id)
893-
.map((x, i) => ({ ...x, blockColor: color[i] }));
896+
.filter((x) => x.Id !== Id)
897+
.map((x, i) => ({ ...x, blockColor: color[i] }));
894898
setSignersData(updateSigner);
895899
const updatePlaceholderUser = signerPos
896-
.filter((x) => x.Id !== Id)
897-
.map((x, i) => ({ ...x, blockColor: color[i] }));
900+
.filter((x) => x.Id !== Id)
901+
.map((x, i) => ({ ...x, blockColor: color[i] }));
898902
// console.log("removePlaceholderUser ", removePlaceholderUser)
903+
904+
const index = signersdata.findIndex((x)=> x.Id === Id)
905+
setUniqueId(updateSigner[index]?.Id ||"");
906+
// setIsSelectId(index === -1 ? 0: index);
907+
setIsSelectId(0);
908+
899909
setSignerPos(updatePlaceholderUser);
900910
setIsMailSend(false);
901911
};
@@ -1051,7 +1061,7 @@ const TemplatePlaceholder = () => {
10511061
handleClose={() => setIsCreateDocModal(false)}
10521062
>
10531063
<div style={{ height: "100%", padding: 20 }}>
1054-
<p>Do you want to create document right now ?</p>
1064+
<p>Do you want to create a document using the template you just created ?</p>
10551065
<div
10561066
style={{
10571067
height: "1px",
@@ -1193,6 +1203,8 @@ const TemplatePlaceholder = () => {
11931203
setSelectedEmail={setSelectedEmail}
11941204
selectedEmail={selectedEmail}
11951205
handleAddSigner={handleAddSigner}
1206+
setUniqueId={setUniqueId}
1207+
setRoleName={setRoleName}
11961208
/>
11971209
</div>
11981210
) : (

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ function FieldsComponent({
3232
isMailSend,
3333
selectedEmail,
3434
setSelectedEmail,
35-
handleAddSigner
35+
handleAddSigner,
36+
setUniqueId,
37+
setRoleName
3638
}) {
3739
const signStyle = pdfUrl ? "disableSign" : "signatureBtn";
3840

@@ -104,6 +106,8 @@ function FieldsComponent({
104106
setIsSelectId(selectedKey);
105107
setContractName(parseData.className);
106108
setSelectedEmail(true);
109+
setUniqueId(parseData.Id);
110+
setRoleName(parseData.Role);
107111
}}
108112
>
109113
<Select.Trigger
@@ -158,7 +162,7 @@ function FieldsComponent({
158162
value={`${ind}|${JSON.stringify(obj)}`}
159163
// value={(obj)}
160164
>
161-
{obj.Role ? obj.Role : obj.Email}
165+
{obj.Email ? obj.Email : obj.Role }
162166
</SelectItem>
163167
);
164168
})}
@@ -193,7 +197,7 @@ function FieldsComponent({
193197
onClick={() => handleAddSigner()}
194198
>
195199
<i className="fa-solid fa-plus"></i>
196-
<span style={{ marginLeft: 2 }}>Add</span>
200+
<span style={{ marginLeft: 2 }}>Add role</span>
197201
</div>
198202
)}
199203
<div

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

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ function RenderPdf({
349349
) : (
350350
<div
351351
style={{
352-
fontSize: "12px",
352+
fontSize: "10px",
353353
color: "black",
354354
justifyContent: "center"
355355
}}
@@ -366,12 +366,12 @@ function RenderPdf({
366366
(sign) => sign.objectId === signerId
367367
);
368368
if (checkSign.length > 0) {
369-
return <p style={{ color: "black" }}> {checkSign[0].Name} </p>;
369+
return <p style={{ color: "black", fontSize: 11 }}> {checkSign[0].Name} </p>;
370370
} else {
371-
return <p style={{ color: "black" }}> {Role} </p>;
371+
return <p style={{ color: "black", fontSize: 11 }}> {Role} </p>;
372372
}
373373
} else {
374-
return <p style={{ color: "black" }}> {Role} </p>;
374+
return <p style={{ color: "black", fontSize: 11 }}> {Role} </p>;
375375
}
376376
};
377377
return (
@@ -619,6 +619,11 @@ function RenderPdf({
619619
>
620620
<i
621621
className="fa-regular fa-user signUserIcon"
622+
onTouchEnd={(e) => {
623+
e.stopPropagation();
624+
handleLinkUser(data.Id);
625+
setUniqueId(data.Id);
626+
}}
622627
onClick={(e) => {
623628
e.stopPropagation();
624629
handleLinkUser(data.Id);
@@ -635,19 +640,30 @@ function RenderPdf({
635640
setIsPageCopy(true);
636641
setSignKey(pos.key);
637642
setSignerObjId(data.signerObjId);
643+
setUniqueId(data.Id)
638644
}}
639645
onClick={(e) => {
640646
e.stopPropagation();
641647
setIsPageCopy(true);
642648
setSignKey(pos.key);
649+
setSignerObjId(data.signerObjId);
650+
setUniqueId(data.Id)
643651
}}
644652
style={{
645653
color: "#188ae2"
646654
}}
647655
></i>
648656
<i
649657
className="fa-regular fa-circle-xmark signCloseBtn"
650-
onTouchStart={(e) => {
658+
onTouchEnd={(e) => {
659+
e.stopPropagation();
660+
handleDeleteSign(
661+
pos.key,
662+
data.Id
663+
);
664+
// data.signerObjId
665+
}}
666+
onClick={(e) => {
651667
e.stopPropagation();
652668
handleDeleteSign(
653669
pos.key,
@@ -662,9 +678,9 @@ function RenderPdf({
662678

663679
<div
664680
style={{
665-
fontSize: "12px",
681+
fontSize: "10px",
666682
color: "black",
667-
fontWeight: "600",
683+
fontWeight: "500",
668684
marginTop: "0px"
669685
}}
670686
>
@@ -772,17 +788,6 @@ function RenderPdf({
772788
}
773789
}}
774790
>
775-
<i
776-
className="fa-regular fa-user signUserIcon"
777-
onClick={(e) => {
778-
e.stopPropagation();
779-
handleLinkUser(data.Id);
780-
setUniqueId(data.Id);
781-
}}
782-
style={{
783-
color: "#188ae2"
784-
}}
785-
></i>
786791
<i
787792
className="fa-regular fa-copy signCopy"
788793
onTouchEnd={(e) => {
@@ -828,7 +833,7 @@ function RenderPdf({
828833
) : (
829834
<div
830835
style={{
831-
fontSize: "12px",
836+
fontSize: "10px",
832837
color: "black",
833838
justifyContent: "center"
834839
}}
@@ -1003,7 +1008,7 @@ function RenderPdf({
10031008
) : (
10041009
<div
10051010
style={{
1006-
fontSize: "12px",
1011+
fontSize: "10px",
10071012
color: "black",
10081013
fontWeight: "600",
10091014
justifyContent: "center",
@@ -1176,7 +1181,7 @@ function RenderPdf({
11761181

11771182
<div
11781183
style={{
1179-
fontSize: "12px",
1184+
fontSize: "10px",
11801185
color: "black",
11811186
justifyContent: "center"
11821187
}}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ function SignerListPlace({
256256
{handleAddSigner && (
257257
<div data-tut="reactourAddbtn" className="addSignerBtn" onClick={() => handleAddSigner()}>
258258
<i className="fa-solid fa-plus"></i>
259-
<span style={{ marginLeft: 2 }}>Add</span>
259+
<span style={{ marginLeft: 2 }}>Add role</span>
260260
</div>
261261
)}
262262
</div>

microfrontends/SignDocuments/src/Component/placeHolderSign.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,7 @@ function PlaceHolderSign() {
912912
setIsAddUser({ [id]: true });
913913
};
914914
const handleAddUser = (data) => {
915+
if(data && data.objectId){
915916
const signerPtr = {
916917
__type: "Pointer",
917918
className: "contracts_Contactbook",
@@ -935,6 +936,7 @@ function PlaceHolderSign() {
935936
// console.log("updateSigner ", updateSigner);
936937

937938
setSignersData(updateSigner);
939+
}
938940
};
939941

940942
const closePopup = () => {
@@ -1206,6 +1208,8 @@ function PlaceHolderSign() {
12061208
isMailSend={isMailSend}
12071209
setSelectedEmail={setSelectedEmail}
12081210
selectedEmail={selectedEmail}
1211+
setUniqueId={setUniqueId}
1212+
setRoleName={setRoleName}
12091213
/>
12101214
</div>
12111215
) : (

microfrontends/SignDocuments/src/css/ModalUi.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
6767
z-index: 1000;
6868
max-height: 80%;
69+
min-width: 90%;
6970
overflow-y: auto;
7071
}
7172
}

0 commit comments

Comments
 (0)