feat: power signing mode

This commit is contained in:
Ephraim Atta-Duncan
2024-10-10 20:23:32 +00:00
parent f05b670d93
commit eb96f315b6
18 changed files with 213 additions and 52 deletions

View File

@ -0,0 +1,43 @@
import { DocumentStatus, RecipientRole, SigningStatus } from '@prisma/client';
import { prisma } from '@documenso/prisma';
type GetNextInboxDocumentOptions = {
email: string | undefined;
};
export const getNextInboxDocument = async ({ email }: GetNextInboxDocumentOptions) => {
if (!email) {
throw new Error('User is required');
}
return await prisma.document.findFirst({
where: {
Recipient: {
some: {
email,
signingStatus: SigningStatus.NOT_SIGNED,
role: {
not: RecipientRole.CC,
},
},
},
status: { not: DocumentStatus.DRAFT },
deletedAt: null,
},
select: {
createdAt: true,
title: true,
Recipient: {
where: {
email,
},
select: {
token: true,
},
},
documentMeta: true,
},
orderBy: [{ createdAt: 'asc' }],
});
};