mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 08:42:12 +10:00
feat: signature rejection (#1472)
## Description Adds support for rejecting a given document informing the document owner. Flows for resolving a rejection don't currently exist so it's up to the document owner to reach out to the recipient and work out a way to move forward via a new document or offline agreement. ## Related Issue ## Changes Made - Added new rejection properties to the recipient schema - Added API endpoints to support rejection - Added email templates for notifying the document owner and recipient - Added a dialog on the signing page to start the rejection flow. ## Testing Performed - Manually tested the flow end to end - Automated tests are planned
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import { TRPCError } from '@trpc/server';
|
||||
|
||||
import { completeDocumentWithToken } from '@documenso/lib/server-only/document/complete-document-with-token';
|
||||
import { rejectDocumentWithToken } from '@documenso/lib/server-only/document/reject-document-with-token';
|
||||
import { setRecipientsForDocument } from '@documenso/lib/server-only/recipient/set-recipients-for-document';
|
||||
import { setRecipientsForTemplate } from '@documenso/lib/server-only/recipient/set-recipients-for-template';
|
||||
import { extractNextApiRequestMetadata } from '@documenso/lib/universal/extract-request-metadata';
|
||||
@ -10,6 +11,7 @@ import {
|
||||
ZAddSignersMutationSchema,
|
||||
ZAddTemplateSignersMutationSchema,
|
||||
ZCompleteDocumentWithTokenMutationSchema,
|
||||
ZRejectDocumentWithTokenMutationSchema,
|
||||
} from './schema';
|
||||
|
||||
export const recipientRouter = router({
|
||||
@ -94,4 +96,26 @@ export const recipientRouter = router({
|
||||
});
|
||||
}
|
||||
}),
|
||||
|
||||
rejectDocumentWithToken: procedure
|
||||
.input(ZRejectDocumentWithTokenMutationSchema)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
try {
|
||||
const { token, documentId, reason } = input;
|
||||
|
||||
return await rejectDocumentWithToken({
|
||||
token,
|
||||
documentId,
|
||||
reason,
|
||||
requestMetadata: extractNextApiRequestMetadata(ctx.req),
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
||||
throw new TRPCError({
|
||||
code: 'BAD_REQUEST',
|
||||
message: 'We were unable to handle this request. Please try again later.',
|
||||
});
|
||||
}
|
||||
}),
|
||||
});
|
||||
|
||||
@ -69,3 +69,14 @@ export const ZCompleteDocumentWithTokenMutationSchema = z.object({
|
||||
export type TCompleteDocumentWithTokenMutationSchema = z.infer<
|
||||
typeof ZCompleteDocumentWithTokenMutationSchema
|
||||
>;
|
||||
|
||||
export const ZRejectDocumentWithTokenMutationSchema = z.object({
|
||||
token: z.string(),
|
||||
documentId: z.number(),
|
||||
reason: z.string(),
|
||||
authOptions: ZRecipientActionAuthSchema.optional(),
|
||||
});
|
||||
|
||||
export type TRejectDocumentWithTokenMutationSchema = z.infer<
|
||||
typeof ZRejectDocumentWithTokenMutationSchema
|
||||
>;
|
||||
|
||||
Reference in New Issue
Block a user