mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
feat: updated signer logic
Signed-off-by: Adithya Krishna <aadithya794@gmail.com>
This commit is contained in:
@ -110,6 +110,8 @@ export const AddSignersFormPartial = ({
|
|||||||
const [showAdvancedSettings, setShowAdvancedSettings] = useState(alwaysShowAdvancedSettings);
|
const [showAdvancedSettings, setShowAdvancedSettings] = useState(alwaysShowAdvancedSettings);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
setValue,
|
||||||
|
getValues,
|
||||||
formState: { errors, isSubmitting },
|
formState: { errors, isSubmitting },
|
||||||
control,
|
control,
|
||||||
} = form;
|
} = form;
|
||||||
@ -164,18 +166,29 @@ export const AddSignersFormPartial = ({
|
|||||||
removeSigner(index);
|
removeSigner(index);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const emptySignerIndex = signers.findIndex(
|
||||||
|
(signer) =>
|
||||||
|
!getValues(`signers.${signers.indexOf(signer)}.name`) ||
|
||||||
|
!getValues(`signers.${signers.indexOf(signer)}.email`),
|
||||||
|
);
|
||||||
|
|
||||||
const onAddSelfSigner = () => {
|
const onAddSelfSigner = () => {
|
||||||
const lastSignerIndex = signers.length - 1;
|
const lastSignerIndex = signers.length - 1;
|
||||||
if (!signers[lastSignerIndex].name || !signers[lastSignerIndex].email) {
|
if (!signers[lastSignerIndex].name && !signers[lastSignerIndex].email) {
|
||||||
onRemoveSigner(lastSignerIndex);
|
onRemoveSigner(lastSignerIndex);
|
||||||
}
|
}
|
||||||
appendSigner({
|
if (emptySignerIndex !== -1) {
|
||||||
formId: nanoid(12),
|
setValue(`signers.${emptySignerIndex}.name`, user?.name ?? '');
|
||||||
name: user?.name ?? '',
|
setValue(`signers.${emptySignerIndex}.email`, user?.email ?? '');
|
||||||
email: user?.email ?? '',
|
} else {
|
||||||
role: RecipientRole.SIGNER,
|
appendSigner({
|
||||||
actionAuth: undefined,
|
formId: nanoid(12),
|
||||||
});
|
name: user?.name ?? '',
|
||||||
|
email: user?.email ?? '',
|
||||||
|
role: RecipientRole.SIGNER,
|
||||||
|
actionAuth: undefined,
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
const onKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user