The Open Source DocuSign Alternative.
TypeScript digital-signaturedocument-signingdocusign-alternativee-signatureesignesignaturenext-authnextjsopen-sourcepades-standardpdfpdf-signpdf-signaturepostgresqlprismaself-hostedsigningtypescript
chore: tidy code
Lucas Smithc21e30d689ce
diff --git a/packages/ui/primitives/document-flow/add-signers.tsx b/packages/ui/primitives/document-flow/add-signers.tsxindex cfee325e1..3ec73f599 100644--- a/packages/ui/primitives/document-flow/add-signers.tsx+++ b/packages/ui/primitives/document-flow/add-signers.tsx@@ -106,11 +106,13 @@ export const AddSignersFormPartial = ({const {setValue,- getValues,formState: { errors, isSubmitting },control,+ watch,} = form;+ const watchedSigners = watch('signers');+const onFormSubmit = form.handleSubmit(onSubmit);const {@@ -122,6 +124,11 @@ export const AddSignersFormPartial = ({name: 'signers',});+ const emptySignerIndex = watchedSigners.findIndex((signer) => !signer.name && !signer.email);+ const isUserAlreadyARecipient = watchedSigners.some(+ (signer) => signer.email.toLowerCase() === user?.email?.toLowerCase(),+ );+const hasBeenSentToRecipientId = (id?: number) => {if (!id) {return false;@@ -161,17 +168,7 @@ export const AddSignersFormPartial = ({removeSigner(index);};- const emptySignerIndex = signers.findIndex(- (signer) =>- !getValues(`signers.${signers.indexOf(signer)}.name`) ||- !getValues(`signers.${signers.indexOf(signer)}.email`),- );-const onAddSelfSigner = () => {- const lastSignerIndex = signers.length - 1;- if (signers[lastSignerIndex].email || signers[lastSignerIndex].name) {- onRemoveSigner(lastSignerIndex);- }if (emptySignerIndex !== -1) {setValue(`signers.${emptySignerIndex}.name`, user?.name ?? '');setValue(`signers.${emptySignerIndex}.email`, user?.email ?? '');@@ -235,11 +232,7 @@ export const AddSignersFormPartial = ({type="email"placeholder="Email"{...field}- disabled={- isSubmitting ||- hasBeenSentToRecipientId(signer.nativeId) ||- signers[index].email === user?.email- }+ disabled={isSubmitting || hasBeenSentToRecipientId(signer.nativeId)}onKeyDown={onKeyDown}/></FormControl>@@ -265,11 +258,7 @@ export const AddSignersFormPartial = ({<Inputplaceholder="Name"{...field}- disabled={- isSubmitting ||- hasBeenSentToRecipientId(signer.nativeId) ||- signers[index].name === user?.name- }+ disabled={isSubmitting || hasBeenSentToRecipientId(signer.nativeId)}onKeyDown={onKeyDown}/></FormControl>@@ -352,14 +341,12 @@ export const AddSignersFormPartial = ({<Plus className="-ml-1 mr-2 h-5 w-5" />Add Signer</Button>+<Buttontype="button"variant="secondary"className="dark:bg-muted dark:hover:bg-muted/80 bg-black/5 hover:bg-black/10"- disabled={- isSubmitting ||- form.getValues('signers').some((signer) => signer.email === user?.email)- }+ disabled={isSubmitting || isUserAlreadyARecipient}onClick={() => onAddSelfSigner()}><Plus className="-ml-1 mr-2 h-5 w-5" />