Skip to content

Commit 7d48742

Browse files
Merge branch 'staging' of https://github.com/OpenSignLabs/OpenSign into raktima-opensignlabs-patch-11
2 parents c422b11 + c20611b commit 7d48742

File tree

17 files changed

+504
-187
lines changed

17 files changed

+504
-187
lines changed

apps/OpenSign/public/static/js/public-template.bundle.js

Lines changed: 26 additions & 24 deletions
Large diffs are not rendered by default.

apps/OpenSign/src/components/AddTeam.js

Lines changed: 33 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,8 @@ const AddTeam = (props) => {
1717
const getTeamList = async () => {
1818
setIsLoader(true);
1919
try {
20-
const extUser = JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
21-
const teamCls = new Parse.Query("contracts_Teams");
22-
teamCls.equalTo("OrganizationId", {
23-
__type: "Pointer",
24-
className: "contracts_Organizations",
25-
objectId: extUser.OrganizationId.objectId
26-
});
27-
teamCls.equalTo("IsActive", true);
28-
const teamRes = await teamCls.find();
20+
const teams = await Parse.Cloud.run("getteams");
21+
const teamRes = JSON.parse(JSON.stringify(teams));
2922
if (teamRes.length > 0) {
3023
const _teamRes = JSON.parse(JSON.stringify(teamRes));
3124
const allUsersteam = _teamRes.find((x) => x.Name === "All Users");
@@ -73,76 +66,47 @@ const AddTeam = (props) => {
7366
}
7467
}
7568
try {
76-
const localUser = JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
7769
setIsLoader(true);
78-
const team = new Parse.Query("contracts_Teams");
79-
team.equalTo("Name", formdata.name);
70+
let data = { Name: formdata.name };
8071
if (updatedAncestors.length > 0) {
8172
const ParentId = updatedAncestors[updatedAncestors.length - 1];
82-
team.equalTo("ParentId", ParentId);
73+
data["ParentId"] = ParentId?.objectId;
74+
data["Ancestors"] = updatedAncestors;
8375
}
84-
if (localUser && localUser.OrganizationId) {
85-
team.equalTo("OrganizationId", {
86-
__type: "Pointer",
87-
className: "contracts_Organizations",
88-
objectId: localUser.OrganizationId.objectId
76+
const newTeamRes = await Parse.Cloud.run("addteam", data);
77+
// console.log("teamRes ", newTeamRes);
78+
if (updatedAncestors.length > 0) {
79+
const ParentId = teamList.find((x) => x.objectId === formdata.team);
80+
props.handleTeamInfo({
81+
objectId: newTeamRes.id,
82+
Name: formdata.name,
83+
ParentId: ParentId,
84+
Ancestors: updatedAncestors,
85+
IsActive: true
8986
});
90-
}
91-
const isTeam = await team.first();
92-
if (isTeam) {
93-
props.setIsAlert({ type: "info", msg: "Teams already exists." });
94-
setIsLoader(false);
9587
} else {
96-
const newTeam = new Parse.Object("contracts_Teams");
97-
newTeam.set("Name", formdata.name);
98-
if (updatedAncestors.length > 0) {
99-
const ParentId = updatedAncestors[updatedAncestors.length - 1];
100-
newTeam.set("ParentId", ParentId);
101-
newTeam.set("Ancestors", updatedAncestors);
102-
}
103-
if (localUser && localUser.OrganizationId) {
104-
newTeam.set("OrganizationId", {
105-
__type: "Pointer",
106-
className: "contracts_Organizations",
107-
objectId: localUser.OrganizationId.objectId
108-
});
109-
}
110-
newTeam.set("IsActive", true);
111-
const newTeamRes = await newTeam.save();
112-
if (updatedAncestors.length > 0) {
113-
const ParentId = teamList.find((x) => x.objectId === formdata.team);
114-
props.handleTeamInfo({
115-
objectId: newTeamRes.id,
116-
Name: formdata.name,
117-
ParentId: ParentId,
118-
Ancestors: updatedAncestors,
119-
IsActive: true
120-
});
121-
} else {
122-
props.handleTeamInfo({
123-
objectId: newTeamRes.id,
124-
Name: formdata.name,
125-
ParentId: "",
126-
Ancestors: "",
127-
IsActive: true
128-
});
129-
}
130-
131-
if (props.closePopup) {
132-
props.closePopup();
133-
}
134-
setFormdata({
135-
name: "",
136-
team: { name: "", objectId: "" }
137-
});
138-
props.setIsAlert({
139-
type: "success",
140-
msg: "Team created successfully."
88+
props.handleTeamInfo({
89+
objectId: newTeamRes.id,
90+
Name: formdata.name,
91+
ParentId: "",
92+
Ancestors: "",
93+
IsActive: true
14194
});
14295
}
96+
if (props.closePopup) {
97+
props.closePopup();
98+
}
99+
setFormdata({ name: "", team: { name: "", objectId: "" } });
100+
props.setIsAlert({ type: "success", msg: "Team created successfully." });
143101
} catch (err) {
144102
console.log("err in save team", err);
145-
props.setIsAlert({ type: "danger", msg: "Something went wrong." });
103+
if (err.code === 137) {
104+
props.setIsAlert({ type: "danger", msg: "Teams already exists." });
105+
} else if (err.code === 102) {
106+
props.setIsAlert({ type: "warning", msg: "Provide team name." });
107+
} else {
108+
props.setIsAlert({ type: "danger", msg: "Something went wrong." });
109+
}
146110
} finally {
147111
setTimeout(() => props.setIsAlert({ type: "success", msg: "" }), 1500);
148112
setIsLoader(false);

apps/OpenSign/src/components/pdf/EmailComponent.js

Lines changed: 60 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useState } from "react";
22
import { saveAs } from "file-saver";
33
import axios from "axios";
44
import { getBase64FromUrl } from "../../constant/Utils";
5-
import { themeColor } from "../../constant/const";
5+
import { themeColor, emailRegex } from "../../constant/const";
66
import printModule from "print-js";
77
import Loader from "../../primitives/Loader";
88
import ModalUi from "../../primitives/ModalUi";
@@ -19,8 +19,9 @@ function EmailComponent({
1919
activeMailAdapter
2020
}) {
2121
const [emailList, setEmailList] = useState([]);
22-
const [emailValue, setEmailValue] = useState();
22+
const [emailValue, setEmailValue] = useState("");
2323
const [isLoading, setIsLoading] = useState(false);
24+
const [emailErr, setEmailErr] = useState(false);
2425
//function for send email
2526
const sendEmail = async () => {
2627
setIsLoading(true);
@@ -111,17 +112,30 @@ function EmailComponent({
111112
//function for get email value
112113
const handleEmailValue = (e) => {
113114
const value = e.target.value;
115+
setEmailErr(false);
114116
setEmailValue(value);
115117
};
116118

117119
//function for save email in array after press enter
118120
const handleEnterPress = (e) => {
121+
const pattern = emailRegex;
122+
const validate = emailValue?.match(pattern);
119123
if (e.key === "Enter" && emailValue) {
120-
setEmailList((prev) => [...prev, emailValue]);
121-
setEmailValue("");
124+
if (validate) {
125+
const emailLowerCase = emailValue?.toLowerCase();
126+
setEmailList((prev) => [...prev, emailLowerCase]);
127+
setEmailValue("");
128+
} else {
129+
setEmailErr(true);
130+
}
122131
} else if (e === "add" && emailValue) {
123-
setEmailList((prev) => [...prev, emailValue]);
124-
setEmailValue("");
132+
if (validate) {
133+
const emailLowerCase = emailValue?.toLowerCase();
134+
setEmailList((prev) => [...prev, emailLowerCase]);
135+
setEmailValue("");
136+
} else {
137+
setEmailErr(true);
138+
}
125139
}
126140
};
127141

@@ -179,7 +193,6 @@ function EmailComponent({
179193
Successfully signed!
180194
</span>
181195
<div className="flex flex-row">
182-
<div></div>
183196
{!isAndroid && (
184197
<button
185198
onClick={handleToPrint}
@@ -203,72 +216,63 @@ function EmailComponent({
203216
Recipients added here will get a copy of the signed document.
204217
</p>
205218
{emailList.length > 0 ? (
206-
<>
207-
<div className="p-0 border-[1.5px] op-border-primary rounded w-full text-[15px]">
208-
<div className="flex flex-row flex-wrap">
209-
{emailList.map((data, ind) => {
210-
return (
211-
<div
212-
className="flex flex-row items-center op-bg-primary m-[4px] rounded-md py-[5px] px-[10px]"
213-
key={ind}
219+
<div className="p-0 border-[1.5px] op-border-primary rounded w-full text-[15px]">
220+
<div className="flex flex-row flex-wrap">
221+
{emailList.map((data, ind) => {
222+
return (
223+
<div
224+
className="flex flex-row items-center op-bg-primary m-[4px] rounded-md py-[5px] px-[10px]"
225+
key={ind}
226+
>
227+
<span className="text-base-100 text-[13px]">
228+
{data}
229+
</span>
230+
<span
231+
className="text-base-100 text-[13px] font-semibold ml-[7px] cursor-pointer"
232+
onClick={() => removeChip(ind)}
214233
>
215-
<span className="text-base-100 text-[13px]">
216-
{data}
217-
</span>
218-
<span
219-
className="text-base-100 text-[13px] font-semibold ml-[7px] cursor-pointer"
220-
onClick={() => removeChip(ind)}
221-
>
222-
<i className="fa-light fa-xmark"></i>
223-
</span>
224-
</div>
225-
);
226-
})}
227-
</div>
228-
{emailList.length <= 9 && (
229-
<input
230-
type="text"
231-
value={emailValue}
232-
className="p-[10px] pb-[20px] rounded w-full text-[15px] bg-transparent outline-none"
233-
onChange={handleEmailValue}
234-
onKeyDown={handleEnterPress}
235-
onBlur={() => {
236-
if (emailValue) {
237-
handleEnterPress("add");
238-
}
239-
}}
240-
required
241-
/>
242-
)}
234+
<i className="fa-light fa-xmark"></i>
235+
</span>
236+
</div>
237+
);
238+
})}
243239
</div>
244-
</>
240+
{emailList.length <= 9 && (
241+
<input
242+
type="email"
243+
value={emailValue}
244+
className="p-[10px] pb-[20px] rounded w-full text-[15px] bg-transparent outline-none"
245+
onChange={handleEmailValue}
246+
onKeyDown={handleEnterPress}
247+
onBlur={() => emailValue && handleEnterPress("add")}
248+
required
249+
/>
250+
)}
251+
</div>
245252
) : (
246253
<div>
247254
<input
248-
type="text"
255+
type="email"
249256
value={emailValue}
250257
className="p-[10px] pb-[20px] rounded w-full text-[15px] outline-none bg-transparent border-[1.5px] op-border-primary"
251258
onChange={handleEmailValue}
252259
onKeyDown={handleEnterPress}
253-
placeholder="Add the email addresses"
254-
onBlur={() => {
255-
if (emailValue) {
256-
handleEnterPress("add");
257-
}
258-
}}
260+
placeholder="Add an email address and hit enter"
261+
onBlur={() => emailValue && handleEnterPress("add")}
259262
required
260263
/>
261264
</div>
262265
)}
266+
{emailErr && (
267+
<p className="text-xs text-[red] ml-1.5 mt-0.5">
268+
please provide correct email address
269+
</p>
270+
)}
263271
<button
264272
className={`${
265273
emailValue ? "cursor-pointer" : "cursor-default"
266274
} op-btn op-btn-primary op-btn-sm m-2 shadow-md`}
267-
onClick={() => {
268-
if (emailValue) {
269-
handleEnterPress("add");
270-
}
271-
}}
275+
onClick={() => emailValue && handleEnterPress("add")}
272276
>
273277
<i className="fa-light fa-plus" aria-hidden="true"></i>
274278
</button>

apps/OpenSign/src/components/pdf/PlaceholderType.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import DatePicker from "react-datepicker";
1313
import "react-datepicker/dist/react-datepicker.css";
1414
import "../../styles/signature.css";
1515
import RegexParser from "regex-parser";
16+
import { emailRegex } from "../../constant/const";
1617
const textWidgetCls =
1718
"w-full h-full md:min-w-full md:min-h-full z-[999] text-[12px] rounded-[2px] border-[1px] border-[#007bff] overflow-hidden resize-none outline-none text-base-content item-center whitespace-pre-wrap";
1819
const selectWidgetCls =
@@ -61,7 +62,7 @@ function PlaceholderType(props) {
6162
if (validateType && validateType !== "text") {
6263
switch (validateType) {
6364
case "email":
64-
regexValidation = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
65+
regexValidation = emailRegex;
6566
validateExpression(regexValidation);
6667
break;
6768
case "number":

apps/OpenSign/src/components/pdf/SignPad.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ function SignPad({
149149
const isWidgetType = currWidgetsDetails?.type;
150150
const signatureType = currWidgetsDetails?.signatureType;
151151
const url = currWidgetsDetails?.SignUrl;
152-
153152
//checking widget type and draw type signature url
154153
if (isInitial) {
155154
if (isWidgetType === "initials" && signatureType === "draw" && url) {
@@ -299,8 +298,9 @@ function SignPad({
299298
<div className="flex flex-row justify-between mt-[3px]">
300299
<div className="flex flex-row justify-between gap-[5px] md:gap-[8px] text-[11px] md:text-base">
301300
{isStamp ? (
302-
<span className="op-link-primary op-link">
303-
{widgetType === "image"
301+
<span className="text-base-content font-bold text-lg">
302+
{widgetType === "image" ||
303+
currWidgetsDetails?.type === "image"
304304
? "Upload image"
305305
: "Upload stamp image"}
306306
</span>

apps/OpenSign/src/constant/const.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ export const templateCls = "contracts_Template";
33
export const documentCls = "contracts_Document";
44
export const themeColor = "#47a3ad";
55
export const iconColor = "#686968";
6-
export const isEnableSubscription =
7-
process.env.REACT_APP_ENABLE_SUBSCRIPTION &&
8-
process.env.REACT_APP_ENABLE_SUBSCRIPTION?.toLowerCase() === "true"
9-
? true
10-
: false;
11-
export const isStaging =
12-
window.location.origin === "https://staging-app.opensignlabs.com";
6+
export const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
7+
export const isEnableSubscription = true;
8+
// process.env.REACT_APP_ENABLE_SUBSCRIPTION &&
9+
// process.env.REACT_APP_ENABLE_SUBSCRIPTION?.toLowerCase() === "true"
10+
// ? true
11+
// : false;
12+
export const isStaging = "http://localhost:3001";
13+
// window.location.origin === "https://staging-app.opensignlabs.com";

0 commit comments

Comments
 (0)