Skip to content

Commit c20611b

Browse files
Merge pull request #965 from OpenSignLabs/multiuser_issue
fix: change send email hint, email validation, remove underline from stamp and image modal
2 parents a334cda + 15d73ee commit c20611b

File tree

5 files changed

+84
-69
lines changed

5 files changed

+84
-69
lines changed

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

Lines changed: 18 additions & 9 deletions
Large diffs are not rendered by default.

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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export const templateCls = "contracts_Template";
33
export const documentCls = "contracts_Document";
44
export const themeColor = "#47a3ad";
55
export const iconColor = "#686968";
6+
export const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
67
export const isEnableSubscription = true;
78
// process.env.REACT_APP_ENABLE_SUBSCRIPTION &&
89
// process.env.REACT_APP_ENABLE_SUBSCRIPTION?.toLowerCase() === "true"

0 commit comments

Comments
 (0)