mirror of
https://github.com/documenso/documenso.git
synced 2025-11-15 01:01:49 +10:00
fix: make sure the user can't add its details more than once
This commit is contained in:
@ -49,6 +49,8 @@ export const AddTemplatePlaceholderRecipientsFormPartial = ({
|
|||||||
recipients.length > 1 ? recipients.length + 1 : 2,
|
recipients.length > 1 ? recipients.length + 1 : 2,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const userIsSelfRecipient = () => signers.some((signer) => signer.email === user?.email);
|
||||||
|
|
||||||
const { currentStep, totalSteps, previousStep } = useStep();
|
const { currentStep, totalSteps, previousStep } = useStep();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -115,9 +117,11 @@ export const AddTemplatePlaceholderRecipientsFormPartial = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onRemoveSigner = (index: number) => {
|
const onRemoveSigner = (index: number) => {
|
||||||
|
const isSelfSigner = signers[index].formId === selfSignerFormId;
|
||||||
|
|
||||||
removeSigner(index);
|
removeSigner(index);
|
||||||
|
|
||||||
if (signers[index].formId === selfSignerFormId) {
|
if (isSelfSigner) {
|
||||||
setSelfSignerFormId(undefined);
|
setSelfSignerFormId(undefined);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -238,7 +242,7 @@ export const AddTemplatePlaceholderRecipientsFormPartial = ({
|
|||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
className="dark:bg-muted dark:hover:bg-muted/80 bg-black/5 hover:bg-black/10"
|
className="dark:bg-muted dark:hover:bg-muted/80 bg-black/5 hover:bg-black/10"
|
||||||
disabled={isSubmitting || !!selfSignerFormId}
|
disabled={isSubmitting || !!selfSignerFormId || userIsSelfRecipient()}
|
||||||
onClick={() => onAddPlaceholderSelfRecipient()}
|
onClick={() => onAddPlaceholderSelfRecipient()}
|
||||||
>
|
>
|
||||||
<Plus className="-ml-1 mr-2 h-5 w-5" />
|
<Plus className="-ml-1 mr-2 h-5 w-5" />
|
||||||
|
|||||||
Reference in New Issue
Block a user