Skip to content

Commit 6c77bbf

Browse files
feat: quick send feature to create & send multiple documents at a time
1 parent 890c3d2 commit 6c77bbf

File tree

9 files changed

+572
-439
lines changed

9 files changed

+572
-439
lines changed

apps/OpenSign/src/components/BulkSendUi.js

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const BulkSendUi = (props) => {
88
const formRef = useRef(null);
99
const [scrollOnNextUpdate, setScrollOnNextUpdate] = useState(false);
1010
const [isSubmit, setIsSubmit] = useState(false);
11+
const [allowedForm, setAllowedForm] = useState(0);
12+
const allowedSigners = 50;
1113
useEffect(() => {
1214
if (scrollOnNextUpdate && formRef.current) {
1315
formRef.current.scrollIntoView({
@@ -37,45 +39,48 @@ const BulkSendUi = (props) => {
3739
}
3840
});
3941
setForms((prevForms) => [...prevForms, { Id: 1, fields: users }]);
42+
const totalForms = Math.floor(allowedSigners / users?.length);
43+
setAllowedForm(totalForms);
4044
}
4145
})();
4246
// eslint-disable-next-line
4347
}, []);
4448
const handleInputChange = (index, signer, fieldIndex) => {
45-
console.log("index", index);
46-
console.log("signer", signer);
47-
console.log("fieldIndex", fieldIndex);
48-
4949
const newForms = [...forms];
5050
newForms[index].fields[fieldIndex].email = signer?.Email
5151
? signer?.Email
5252
: signer || "";
5353
newForms[index].fields[fieldIndex].signer = signer?.objectId ? signer : "";
54-
console.log("newForms[index] ", newForms[index]);
5554
setForms(newForms);
5655
};
5756

5857
const handleAddForm = (e) => {
5958
e.preventDefault();
60-
if (props?.Placeholders.length > 0) {
61-
let newForm = [];
62-
props?.Placeholders?.forEach((element) => {
63-
if (!element.signerObjId) {
64-
newForm = [
65-
...newForm,
66-
{
67-
fieldId: element.Id,
68-
email: "",
69-
label: element.Role,
70-
signer: {}
71-
}
72-
];
73-
}
74-
});
75-
setForms([...forms, { Id: formId, fields: newForm }]);
59+
// Check if the quick send limit has been reached
60+
if (forms?.length < allowedForm) {
61+
if (props?.Placeholders.length > 0) {
62+
let newForm = [];
63+
props?.Placeholders?.forEach((element) => {
64+
if (!element.signerObjId) {
65+
newForm = [
66+
...newForm,
67+
{
68+
fieldId: element.Id,
69+
email: "",
70+
label: element.Role,
71+
signer: {}
72+
}
73+
];
74+
}
75+
});
76+
setForms([...forms, { Id: formId, fields: newForm }]);
77+
}
78+
setFormId(formId + 1);
79+
setScrollOnNextUpdate(true);
80+
} else {
81+
// If the limit has been reached, throw an error with the appropriate message
82+
alert("Quick send reached limit.");
7683
}
77-
setFormId(formId + 1);
78-
setScrollOnNextUpdate(true);
7984
};
8085

8186
const handleRemoveForm = (index) => {
@@ -102,7 +107,6 @@ const BulkSendUi = (props) => {
102107
);
103108
// If a matching field is found, update the email value in the placeholder
104109
const signer = field?.signer?.objectId ? field.signer : {};
105-
console.log("signer ", signer);
106110
if (field) {
107111
return {
108112
...placeholder,

apps/OpenSign/src/components/shared/fields/SuggestionInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const SuggestionInput = (props) => {
6767
value={inputValue}
6868
onChange={handleInputChange}
6969
placeholder="Enter text..."
70-
className="w-full border border-gray-300 p-2 text-black rounded"
70+
className="w-full border-[1px] border-gray-400 p-2 text-black rounded"
7171
required={props.required}
7272
/>
7373
{showSuggestions && (

0 commit comments

Comments
 (0)