mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 04:22:32 +10:00
feat: add typed signature (#1357)
Add the ability to insert typed signatures. Once the signature field is placed on the document, a checkbox appears in the document editor where the document owner can allow signers to add typed signatures. Typed signatures are disabled by default. 
This commit is contained in:
@ -42,6 +42,7 @@ import {
|
||||
ZSetSettingsForDocumentMutationSchema,
|
||||
ZSetSigningOrderForDocumentMutationSchema,
|
||||
ZSetTitleForDocumentMutationSchema,
|
||||
ZUpdateTypedSignatureSettingsMutationSchema,
|
||||
} from './schema';
|
||||
|
||||
export const documentRouter = router({
|
||||
@ -332,6 +333,46 @@ export const documentRouter = router({
|
||||
}
|
||||
}),
|
||||
|
||||
updateTypedSignatureSettings: authenticatedProcedure
|
||||
.input(ZUpdateTypedSignatureSettingsMutationSchema)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
try {
|
||||
const { documentId, teamId, typedSignatureEnabled } = input;
|
||||
|
||||
const document = await getDocumentById({
|
||||
id: documentId,
|
||||
teamId,
|
||||
userId: ctx.user.id,
|
||||
}).catch(() => null);
|
||||
|
||||
if (!document) {
|
||||
throw new TRPCError({
|
||||
code: 'NOT_FOUND',
|
||||
message: 'Document not found',
|
||||
});
|
||||
}
|
||||
|
||||
return await upsertDocumentMeta({
|
||||
documentId,
|
||||
typedSignatureEnabled,
|
||||
userId: ctx.user.id,
|
||||
requestMetadata: extractNextApiRequestMetadata(ctx.req),
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
||||
if (err instanceof TRPCError) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
throw new TRPCError({
|
||||
code: 'BAD_REQUEST',
|
||||
message:
|
||||
'We were unable to update the settings for this document. Please try again later.',
|
||||
});
|
||||
}
|
||||
}),
|
||||
|
||||
sendDocument: authenticatedProcedure
|
||||
.input(ZSendDocumentMutationSchema)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
|
||||
Reference in New Issue
Block a user