Skip to content

Commit 5c3f967

Browse files
fix: add validation of signature widgetat in quick send flow, update SentToOthers field when document is in inProgress , resolve resend nonexist email issue
1 parent 2900464 commit 5c3f967

File tree

9 files changed

+194
-127
lines changed

9 files changed

+194
-127
lines changed

apps/OpenSign/src/components/BulkSendUi.js

Lines changed: 80 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,22 @@ const BulkSendUi = (props) => {
99
const [scrollOnNextUpdate, setScrollOnNextUpdate] = useState(false);
1010
const [isSubmit, setIsSubmit] = useState(false);
1111
const [allowedForm, setAllowedForm] = useState(0);
12+
const [isSignatureExist, setIsSignatureExist] = useState();
1213
const allowedSigners = 50;
14+
useEffect(() => {
15+
signatureExist();
16+
}, []);
17+
18+
//function to check atleast one signature field exist
19+
const signatureExist = () => {
20+
const getPlaceholder = props.item?.Placeholders;
21+
const checkIsSignatureExistt = getPlaceholder?.every((placeholderObj) =>
22+
placeholderObj?.placeHolder?.some((holder) =>
23+
holder?.pos?.some((posItem) => posItem?.type === "signature")
24+
)
25+
);
26+
setIsSignatureExist(checkIsSignatureExistt);
27+
};
1328
useEffect(() => {
1429
if (scrollOnNextUpdate && formRef.current) {
1530
formRef.current.scrollIntoView({
@@ -165,65 +180,73 @@ const BulkSendUi = (props) => {
165180
</div>
166181
)}
167182
{props.Placeholders?.length > 0 ? (
168-
<>
169-
{props.Placeholders?.some((x) => !x.signerObjId) ? (
170-
<form onSubmit={handleSubmit}>
171-
<div className=" min-h-max max-h-[250px] overflow-y-auto">
172-
{forms?.map((form, index) => (
173-
<div
174-
key={form.Id}
175-
className="p-3 rounded-xl border-[1px] border-gray-400 m-4 bg-white text-black grid grid-cols-1 md:grid-cols-2 gap-2 relative"
183+
isSignatureExist ? (
184+
<>
185+
{props.Placeholders?.some((x) => !x.signerObjId) ? (
186+
<form onSubmit={handleSubmit}>
187+
<div className=" min-h-max max-h-[250px] overflow-y-auto">
188+
{forms?.map((form, index) => (
189+
<div
190+
key={form.Id}
191+
className="p-3 rounded-xl border-[1px] border-gray-400 m-4 bg-white text-black grid grid-cols-1 md:grid-cols-2 gap-2 relative"
192+
>
193+
{form?.fields?.map((field, fieldIndex) => (
194+
<div className="flex flex-col " key={field.fieldId}>
195+
<label>{field.label}</label>
196+
<SuggestionInput
197+
required
198+
type="email"
199+
value={field.value}
200+
index={fieldIndex}
201+
onChange={(signer) =>
202+
handleInputChange(index, signer, fieldIndex)
203+
}
204+
/>
205+
</div>
206+
))}
207+
{forms?.length > 1 && (
208+
<button
209+
onClick={() => handleRemoveForm(index)}
210+
className="absolute right-3 top-1 border border-gray-300 rounded-lg px-2 py-1"
211+
>
212+
<i className="fa-solid fa-trash"></i>
213+
</button>
214+
)}
215+
<div ref={formRef}></div>
216+
</div>
217+
))}
218+
</div>
219+
<div className="flex flex-col mx-4 mb-4 gap-3">
220+
<button
221+
onClick={handleAddForm}
222+
className="bg-[#32a3ac] p-2 text-white w-full rounded-full focus:outline-none"
176223
>
177-
{form?.fields?.map((field, fieldIndex) => (
178-
<div className="flex flex-col " key={field.fieldId}>
179-
<label>{field.label}</label>
180-
<SuggestionInput
181-
required
182-
type="email"
183-
value={field.value}
184-
index={fieldIndex}
185-
onChange={(signer) =>
186-
handleInputChange(index, signer, fieldIndex)
187-
}
188-
/>
189-
</div>
190-
))}
191-
{forms?.length > 1 && (
192-
<button
193-
onClick={() => handleRemoveForm(index)}
194-
className="absolute right-3 top-1 border border-gray-300 rounded-lg px-2 py-1"
195-
>
196-
<i className="fa-solid fa-trash"></i>
197-
</button>
198-
)}
199-
<div ref={formRef}></div>
200-
</div>
201-
))}
202-
</div>
203-
<div className="flex flex-col mx-4 mb-4 gap-3">
204-
<button
205-
onClick={handleAddForm}
206-
className="bg-[#32a3ac] p-2 text-white w-full rounded-full focus:outline-none"
207-
>
208-
<i className="fa-solid fa-plus"></i> <span>Add new</span>
209-
</button>
210-
<button
211-
type="submit"
212-
className="bg-[#32a3ac] p-2 text-white w-full rounded-full focus:outline-none"
213-
>
214-
<i className="fa-solid fa-paper-plane"></i> <span>Send</span>
215-
</button>
224+
<i className="fa-solid fa-plus"></i> <span>Add new</span>
225+
</button>
226+
<button
227+
type="submit"
228+
className="bg-[#32a3ac] p-2 text-white w-full rounded-full focus:outline-none"
229+
>
230+
<i className="fa-solid fa-paper-plane"></i>{" "}
231+
<span>Send</span>
232+
</button>
233+
</div>
234+
</form>
235+
) : (
236+
<div className="text-black p-3 bg-white w-full text-sm md:text-base flex justify-center items-center">
237+
All roles in this document are currently linked to contacts. To
238+
&apos;quick send&apos; copies of this template to multiple
239+
signers, please ensure that at least one role is not linked to
240+
any contact.
216241
</div>
217-
</form>
218-
) : (
219-
<div className="text-black p-3 bg-white w-full text-sm md:text-base flex justify-center items-center">
220-
All roles in this document are currently linked to contacts. To
221-
&apos;quick send&apos; copies of this template to multiple
222-
signers, please ensure that at least one role is not linked to any
223-
contact.
224-
</div>
225-
)}
226-
</>
242+
)}
243+
</>
244+
) : (
245+
<div className="text-black p-3 bg-white w-full text-sm md:text-base flex justify-center items-center">
246+
Please ensure there&#39;s at least one signature widget added for
247+
all recipients.
248+
</div>
249+
)
227250
) : (
228251
<div className="text-black p-3 bg-white w-full text-sm md:text-base flex justify-center items-center">
229252
Please add at least one role to this template in order to &apos;quick

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,9 @@ function RenderPdf({
206206
const checkSignedSignes = (data) => {
207207
let checkSign = [];
208208
//condition to handle quick send flow and using normal request sign flow
209-
if (signedSigners[0]?.Id) {
210-
checkSign = signedSigners.filter((sign) => sign.Id === data.Id);
211-
} else {
212-
checkSign = signedSigners.filter(
213-
(sign) => sign.objectId === data.signerObjId
214-
);
215-
}
209+
checkSign = signedSigners.filter(
210+
(sign) => sign?.Id === data?.Id || sign?.objectId === data?.signerObjId
211+
);
216212
if (data.signerObjId === signerObjectId) {
217213
setCurrentSigner(true);
218214
}

apps/OpenSign/src/constant/Utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ export const createDocument = async (template, placeholders, signerData) => {
669669
Name: Doc.Name,
670670
URL: Doc.URL,
671671
SignedUrl: Doc.SignedUrl,
672+
SentToOthers: Doc.SentToOthers,
672673
Description: Doc.Description,
673674
Note: Doc.Note,
674675
Placeholders: placeholdersArr,

apps/OpenSign/src/pages/PdfRequestFiles.js

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -403,25 +403,34 @@ function PdfRequestFiles() {
403403

404404
let signers = [];
405405
let unSignedSigner = [];
406-
//`emailExist` variable to handle condition for quick send flow and show unsigned signers list
407-
const emailExist = documentData[0].Placeholders[0]?.email;
408406

407+
const placeholdersOrSigners = [];
408+
for (const placeholder of documentData[0].Placeholders) {
409+
//`emailExist` variable to handle condition for quick send flow and show unsigned signers list
410+
const emailExist = placeholder?.email;
411+
if (emailExist) {
412+
placeholdersOrSigners.push(placeholder);
413+
} else {
414+
const getSignerData = documentData[0].Signers.filter(
415+
(data) => data.objectId === placeholder?.signerObjId
416+
);
417+
placeholdersOrSigners.push(getSignerData[0]);
418+
}
419+
}
409420
//condition to check already signed document by someone
410421
if (audittrailData && audittrailData.length > 0) {
411422
setIsDocId(true);
412-
const placeholdersOrSigners = emailExist
413-
? documentData[0].Placeholders
414-
: documentData[0].Signers;
415423

416424
for (const item of placeholdersOrSigners) {
425+
const checkEmail = item?.email;
417426
//if email exist then compare user signed by using email else signers objectId
418-
const emailOrId = emailExist ? item.email : item.objectId;
427+
const emailOrId = checkEmail ? item.email : item.objectId;
419428
//`isSignedSignature` variable to handle break loop whenever it get true
420429
let isSignedSignature = false;
421430
//checking the signer who signed the document by using audit trail details.
422431
//and save signedSigners and unsignedSigners details
423432
for (const doc of audittrailData) {
424-
const signedExist = emailExist
433+
const signedExist = checkEmail
425434
? doc?.UserPtr.Email
426435
: doc?.UserPtr.objectId;
427436

@@ -441,12 +450,7 @@ function PdfRequestFiles() {
441450
} else {
442451
//else condition is show there are no details in audit trail then direct push all signers details
443452
//in unsignedsigners array
444-
let unsigned = [];
445-
const placeholdersOrSigners = emailExist
446-
? documentData[0].Placeholders
447-
: documentData[0].Signers;
448-
unsigned.push(placeholdersOrSigners);
449-
setUnSignedSigners(unsigned[0]);
453+
setUnSignedSigners(placeholdersOrSigners);
450454
setSignerPos(documentData[0].Placeholders);
451455
}
452456
setPdfDetails(documentData);
@@ -1000,8 +1004,10 @@ function PdfRequestFiles() {
10001004
}
10011005

10021006
const getFirstLetter = (name) => {
1003-
const firstLetter = name.charAt(0);
1004-
return firstLetter;
1007+
if (name) {
1008+
const firstLetter = name.charAt(0);
1009+
return firstLetter;
1010+
}
10051011
};
10061012
//function for image upload or update
10071013
const onImageChange = (event) => {
@@ -1123,8 +1129,12 @@ function PdfRequestFiles() {
11231129
};
11241130
const checkUserNameColor = (obj) => {
11251131
const getBackColor = checkSignerBackColor(obj);
1126-
const color = darkenColor(getBackColor, 0.4);
1127-
return color;
1132+
if (getBackColor) {
1133+
const color = darkenColor(getBackColor, 0.4);
1134+
return color;
1135+
} else {
1136+
return "#abd1d0";
1137+
}
11281138
};
11291139

11301140
//function for set decline true on press decline button

apps/OpenSign/src/pages/PlaceHolderSign.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,7 @@ function PlaceHolderSign() {
936936
Placeholders: filterPrefill,
937937
SignedUrl: pdfUrl,
938938
Signers: signers,
939+
SentToOthers: true,
939940
ExpiryDate: {
940941
iso: updateExpiryDate,
941942
__type: "Date"
@@ -945,7 +946,8 @@ function PlaceHolderSign() {
945946
data = {
946947
Placeholders: filterPrefill,
947948
SignedUrl: pdfUrl,
948-
Signers: signers
949+
Signers: signers,
950+
SentToOthers: true
949951
};
950952
}
951953
await axios

0 commit comments

Comments
 (0)