Skip to content

The Open Source DocuSign Alternative.

feat: update add self signer logic

Adithya Krishnabde0f5893fa0
diff --git a/packages/ui/primitives/document-flow/add-signers.tsx b/packages/ui/primitives/document-flow/add-signers.tsx
index 2f9f2f234..3227cdeb6 100644
--- a/packages/ui/primitives/document-flow/add-signers.tsx
+++ b/packages/ui/primitives/document-flow/add-signers.tsx
@@ -138,16 +138,6 @@ export const AddSignersFormPartial = ({
);
};
- const onAddSelfSigner = () => {
- appendSigner({
- formId: nanoid(12),
- name: user?.name ?? '',
- email: user?.email ?? '',
- role: RecipientRole.SIGNER,
- actionAuth: undefined,
- });
- };
-
const onAddSigner = () => {
appendSigner({
formId: nanoid(12),
@@ -174,6 +164,20 @@ export const AddSignersFormPartial = ({
removeSigner(index);
};
+ const onAddSelfSigner = () => {
+ const lastSignerIndex = signers.length - 1;
+ if(!signers[lastSignerIndex].name || !signers[lastSignerIndex].email){
+ onRemoveSigner(lastSignerIndex)
+ }
+ appendSigner({
+ formId: nanoid(12),
+ name: user?.name ?? '',
+ email: user?.email ?? '',
+ role: RecipientRole.SIGNER,
+ actionAuth: undefined,
+ });
+ };
+
const onKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
if (event.key === 'Enter' && event.target instanceof HTMLInputElement) {
onAddSigner();