mirror of
https://github.com/documenso/documenso.git
synced 2025-11-16 09:41:35 +10:00
chore: refactor
This commit is contained in:
@ -241,7 +241,6 @@ export const DocumentSigningCheckboxField = ({
|
|||||||
void executeActionAuthProcedure({
|
void executeActionAuthProcedure({
|
||||||
onReauthFormSubmit: async (authOptions) => await onSign(authOptions),
|
onReauthFormSubmit: async (authOptions) => await onSign(authOptions),
|
||||||
actionTarget: field.type,
|
actionTarget: field.type,
|
||||||
isEnterprise,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [checkedValues, isLengthConditionMet, field.inserted]);
|
}, [checkedValues, isLengthConditionMet, field.inserted]);
|
||||||
|
|||||||
@ -148,7 +148,6 @@ export const DocumentSigningDropdownField = ({
|
|||||||
void executeActionAuthProcedure({
|
void executeActionAuthProcedure({
|
||||||
onReauthFormSubmit: async (authOptions) => await onSign(authOptions),
|
onReauthFormSubmit: async (authOptions) => await onSign(authOptions),
|
||||||
actionTarget: field.type,
|
actionTarget: field.type,
|
||||||
isEnterprise,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [localChoice]);
|
}, [localChoice]);
|
||||||
@ -158,7 +157,6 @@ export const DocumentSigningDropdownField = ({
|
|||||||
void executeActionAuthProcedure({
|
void executeActionAuthProcedure({
|
||||||
onReauthFormSubmit: async (authOptions) => await onSign(authOptions),
|
onReauthFormSubmit: async (authOptions) => await onSign(authOptions),
|
||||||
actionTarget: field.type,
|
actionTarget: field.type,
|
||||||
isEnterprise,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
@ -91,7 +91,6 @@ export const DocumentSigningFieldContainer = ({
|
|||||||
// Do nothing since the user should be redirected.
|
// Do nothing since the user should be redirected.
|
||||||
},
|
},
|
||||||
actionTarget: field.type,
|
actionTarget: field.type,
|
||||||
isEnterprise,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -109,7 +108,6 @@ export const DocumentSigningFieldContainer = ({
|
|||||||
await executeActionAuthProcedure({
|
await executeActionAuthProcedure({
|
||||||
onReauthFormSubmit: onSign,
|
onReauthFormSubmit: onSign,
|
||||||
actionTarget: field.type,
|
actionTarget: field.type,
|
||||||
isEnterprise,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -120,7 +120,6 @@ export const DocumentSigningForm = ({
|
|||||||
try {
|
try {
|
||||||
await executeActionAuthProcedure({
|
await executeActionAuthProcedure({
|
||||||
actionTarget: 'DOCUMENT',
|
actionTarget: 'DOCUMENT',
|
||||||
isEnterprise,
|
|
||||||
onReauthFormSubmit: async (authOptions) => {
|
onReauthFormSubmit: async (authOptions) => {
|
||||||
await completeDocument(authOptions, nextSigner);
|
await completeDocument(authOptions, nextSigner);
|
||||||
},
|
},
|
||||||
@ -241,7 +240,6 @@ export const DocumentSigningForm = ({
|
|||||||
onSignatureComplete={async (nextSigner) => {
|
onSignatureComplete={async (nextSigner) => {
|
||||||
await executeActionAuthProcedure({
|
await executeActionAuthProcedure({
|
||||||
actionTarget: 'DOCUMENT',
|
actionTarget: 'DOCUMENT',
|
||||||
isEnterprise,
|
|
||||||
onReauthFormSubmit: async (authOptions) => {
|
onReauthFormSubmit: async (authOptions) => {
|
||||||
await completeDocument(authOptions, nextSigner);
|
await completeDocument(authOptions, nextSigner);
|
||||||
},
|
},
|
||||||
@ -427,7 +425,6 @@ export const DocumentSigningForm = ({
|
|||||||
onSignatureComplete={async (nextSigner) => {
|
onSignatureComplete={async (nextSigner) => {
|
||||||
await executeActionAuthProcedure({
|
await executeActionAuthProcedure({
|
||||||
actionTarget: 'DOCUMENT',
|
actionTarget: 'DOCUMENT',
|
||||||
isEnterprise,
|
|
||||||
onReauthFormSubmit: async (authOptions) => {
|
onReauthFormSubmit: async (authOptions) => {
|
||||||
await completeDocument(authOptions, nextSigner);
|
await completeDocument(authOptions, nextSigner);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -85,7 +85,6 @@ export const DocumentSigningNameField = ({
|
|||||||
void executeActionAuthProcedure({
|
void executeActionAuthProcedure({
|
||||||
onReauthFormSubmit: async (authOptions) => await onSign(authOptions, localFullName),
|
onReauthFormSubmit: async (authOptions) => await onSign(authOptions, localFullName),
|
||||||
actionTarget: field.type,
|
actionTarget: field.type,
|
||||||
isEnterprise,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -112,7 +112,6 @@ export const DocumentSigningNumberField = ({
|
|||||||
void executeActionAuthProcedure({
|
void executeActionAuthProcedure({
|
||||||
onReauthFormSubmit: async (authOptions) => await onSign(authOptions),
|
onReauthFormSubmit: async (authOptions) => await onSign(authOptions),
|
||||||
actionTarget: field.type,
|
actionTarget: field.type,
|
||||||
isEnterprise,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -223,7 +222,6 @@ export const DocumentSigningNumberField = ({
|
|||||||
void executeActionAuthProcedure({
|
void executeActionAuthProcedure({
|
||||||
onReauthFormSubmit: async (authOptions) => await onSign(authOptions),
|
onReauthFormSubmit: async (authOptions) => await onSign(authOptions),
|
||||||
actionTarget: field.type,
|
actionTarget: field.type,
|
||||||
isEnterprise,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
@ -144,7 +144,6 @@ export const DocumentSigningRadioField = ({
|
|||||||
void executeActionAuthProcedure({
|
void executeActionAuthProcedure({
|
||||||
onReauthFormSubmit: async (authOptions) => await onSign(authOptions),
|
onReauthFormSubmit: async (authOptions) => await onSign(authOptions),
|
||||||
actionTarget: field.type,
|
actionTarget: field.type,
|
||||||
isEnterprise,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [selectedOption, field]);
|
}, [selectedOption, field]);
|
||||||
|
|||||||
@ -110,7 +110,6 @@ export const DocumentSigningSignatureField = ({
|
|||||||
void executeActionAuthProcedure({
|
void executeActionAuthProcedure({
|
||||||
onReauthFormSubmit: async (authOptions) => await onSign(authOptions, localSignature),
|
onReauthFormSubmit: async (authOptions) => await onSign(authOptions, localSignature),
|
||||||
actionTarget: field.type,
|
actionTarget: field.type,
|
||||||
isEnterprise,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -124,7 +124,6 @@ export const DocumentSigningTextField = ({
|
|||||||
void executeActionAuthProcedure({
|
void executeActionAuthProcedure({
|
||||||
onReauthFormSubmit: async (authOptions) => await onSign(authOptions),
|
onReauthFormSubmit: async (authOptions) => await onSign(authOptions),
|
||||||
actionTarget: field.type,
|
actionTarget: field.type,
|
||||||
isEnterprise,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -218,7 +217,6 @@ export const DocumentSigningTextField = ({
|
|||||||
void executeActionAuthProcedure({
|
void executeActionAuthProcedure({
|
||||||
onReauthFormSubmit: async (authOptions) => await onSign(authOptions),
|
onReauthFormSubmit: async (authOptions) => await onSign(authOptions),
|
||||||
actionTarget: field.type,
|
actionTarget: field.type,
|
||||||
isEnterprise,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
@ -152,7 +152,7 @@ export const TemplateEditForm = ({
|
|||||||
|
|
||||||
toast({
|
toast({
|
||||||
title: _(msg`Error`),
|
title: _(msg`Error`),
|
||||||
description: _(msg`An error occurred while updating the document settings.`),
|
description: _(msg`An error occurred while updating the template settings.`),
|
||||||
variant: 'destructive',
|
variant: 'destructive',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import { prisma } from '@documenso/prisma';
|
|||||||
|
|
||||||
import { AppError, AppErrorCode } from '../../errors/app-error';
|
import { AppError, AppErrorCode } from '../../errors/app-error';
|
||||||
import type { TDocumentAccessAuthTypes, TDocumentActionAuthTypes } from '../../types/document-auth';
|
import type { TDocumentAccessAuthTypes, TDocumentActionAuthTypes } from '../../types/document-auth';
|
||||||
|
import { DocumentAuth } from '../../types/document-auth';
|
||||||
import { createDocumentAuthOptions, extractDocumentAuthMethods } from '../../utils/document-auth';
|
import { createDocumentAuthOptions, extractDocumentAuthMethods } from '../../utils/document-auth';
|
||||||
|
|
||||||
export type UpdateTemplateOptions = {
|
export type UpdateTemplateOptions = {
|
||||||
@ -73,7 +74,11 @@ export const updateTemplate = async ({
|
|||||||
data?.globalActionAuth === undefined ? documentGlobalActionAuth : data.globalActionAuth;
|
data?.globalActionAuth === undefined ? documentGlobalActionAuth : data.globalActionAuth;
|
||||||
|
|
||||||
// Check if user has permission to set the global action auth.
|
// Check if user has permission to set the global action auth.
|
||||||
if (newGlobalActionAuth) {
|
// Only ACCOUNT and PASSKEY require enterprise permissions
|
||||||
|
if (
|
||||||
|
newGlobalActionAuth &&
|
||||||
|
(newGlobalActionAuth === DocumentAuth.ACCOUNT || newGlobalActionAuth === DocumentAuth.PASSKEY)
|
||||||
|
) {
|
||||||
const isDocumentEnterprise = await isUserEnterprise({
|
const isDocumentEnterprise = await isUserEnterprise({
|
||||||
userId,
|
userId,
|
||||||
teamId,
|
teamId,
|
||||||
@ -81,7 +86,7 @@ export const updateTemplate = async ({
|
|||||||
|
|
||||||
if (!isDocumentEnterprise) {
|
if (!isDocumentEnterprise) {
|
||||||
throw new AppError(AppErrorCode.UNAUTHORIZED, {
|
throw new AppError(AppErrorCode.UNAUTHORIZED, {
|
||||||
message: 'You do not have permission to set the action auth',
|
message: 'You do not have permission to set this action auth type',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,14 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { useLingui } from '@lingui/react/macro';
|
import { Trans, useLingui } from '@lingui/react/macro';
|
||||||
import { Trans } from '@lingui/react/macro';
|
import {
|
||||||
import { DocumentVisibility, TeamMemberRole } from '@prisma/client';
|
DocumentDistributionMethod,
|
||||||
import { DocumentDistributionMethod, type Field, type Recipient } from '@prisma/client';
|
DocumentVisibility,
|
||||||
|
type Field,
|
||||||
|
type Recipient,
|
||||||
|
TeamMemberRole,
|
||||||
|
} from '@prisma/client';
|
||||||
import { InfoIcon } from 'lucide-react';
|
import { InfoIcon } from 'lucide-react';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { match } from 'ts-pattern';
|
import { match } from 'ts-pattern';
|
||||||
@ -360,24 +364,26 @@ export const AddTemplateSettingsFormPartial = ({
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{isEnterprise && (
|
<FormField
|
||||||
<FormField
|
control={form.control}
|
||||||
control={form.control}
|
name="globalActionAuth"
|
||||||
name="globalActionAuth"
|
render={({ field }) => (
|
||||||
render={({ field }) => (
|
<FormItem>
|
||||||
<FormItem>
|
<FormLabel className="flex flex-row items-center">
|
||||||
<FormLabel className="flex flex-row items-center">
|
<Trans>Recipient action authentication</Trans>
|
||||||
<Trans>Recipient action authentication</Trans>
|
<DocumentGlobalAuthActionTooltip />
|
||||||
<DocumentGlobalAuthActionTooltip />
|
</FormLabel>
|
||||||
</FormLabel>
|
|
||||||
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<DocumentGlobalAuthActionSelect {...field} onValueChange={field.onChange} />
|
<DocumentGlobalAuthActionSelect
|
||||||
</FormControl>
|
{...field}
|
||||||
</FormItem>
|
onValueChange={field.onChange}
|
||||||
)}
|
isDocumentEnterprise={isEnterprise}
|
||||||
/>
|
/>
|
||||||
)}
|
</FormControl>
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
{distributionMethod === DocumentDistributionMethod.EMAIL && (
|
{distributionMethod === DocumentDistributionMethod.EMAIL && (
|
||||||
<Accordion type="multiple">
|
<Accordion type="multiple">
|
||||||
|
|||||||
Reference in New Issue
Block a user