mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 04:22:32 +10:00
## 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
33 lines
840 B
TypeScript
33 lines
840 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
import { ReadStatus, SendStatus, SigningStatus } from '@documenso/prisma/client';
|
|
|
|
export const getRecipientsStats = async () => {
|
|
const results = await prisma.recipient.groupBy({
|
|
by: ['readStatus', 'signingStatus', 'sendStatus'],
|
|
_count: true,
|
|
});
|
|
|
|
const stats = {
|
|
TOTAL_RECIPIENTS: 0,
|
|
[ReadStatus.OPENED]: 0,
|
|
[ReadStatus.NOT_OPENED]: 0,
|
|
[SigningStatus.SIGNED]: 0,
|
|
[SigningStatus.NOT_SIGNED]: 0,
|
|
[SigningStatus.REJECTED]: 0,
|
|
[SendStatus.SENT]: 0,
|
|
[SendStatus.NOT_SENT]: 0,
|
|
};
|
|
|
|
results.forEach((result) => {
|
|
const { readStatus, signingStatus, sendStatus, _count } = result;
|
|
|
|
stats[readStatus] += _count;
|
|
stats[signingStatus] += _count;
|
|
stats[sendStatus] += _count;
|
|
|
|
stats.TOTAL_RECIPIENTS += _count;
|
|
});
|
|
|
|
return stats;
|
|
};
|