Skip to content

The Open Source DocuSign Alternative.

chore: refactor removal logic

Adithya Krishna917c83fc5f68
diff --git a/packages/ui/primitives/document-flow/add-signers.tsx b/packages/ui/primitives/document-flow/add-signers.tsx
index b83e5064c..b62d4c433 100644
--- a/packages/ui/primitives/document-flow/add-signers.tsx
+++ b/packages/ui/primitives/document-flow/add-signers.tsx
@@ -116,6 +116,7 @@ export const AddSignersFormPartial = ({
const onFormSubmit = form.handleSubmit(onSubmit);
+
const {
append: appendSigner,
fields: signers,
@@ -124,7 +125,7 @@ export const AddSignersFormPartial = ({
control,
name: 'signers',
});
-
+
const hasBeenSentToRecipientId = (id?: number) => {
if (!id) {
return false;
@@ -165,7 +166,10 @@ export const AddSignersFormPartial = ({
};
const onAddSelfSigner = () => {
- if(signers.length !== 0) onRemoveSigner(0);
+ const lastSignerIndex = signers.length - 1;
+ if(!signers[lastSignerIndex].name || !signers[lastSignerIndex].email){
+ onRemoveSigner(lastSignerIndex)
+ }
appendSigner({
formId: nanoid(12),
name: user?.name ?? '',