mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 04:22:32 +10:00
56 lines
1.0 KiB
TypeScript
56 lines
1.0 KiB
TypeScript
import { prisma } from '@documenso/prisma';
|
|
|
|
import { getDocumentWhereInput } from '../document/get-document-by-id';
|
|
|
|
export interface GetRecipientsForDocumentOptions {
|
|
documentId: number;
|
|
userId: number;
|
|
teamId: number;
|
|
}
|
|
|
|
export const getRecipientsForDocument = async ({
|
|
documentId,
|
|
userId,
|
|
teamId,
|
|
}: GetRecipientsForDocumentOptions) => {
|
|
const { documentWhereInput } = await getDocumentWhereInput({
|
|
documentId,
|
|
userId,
|
|
teamId,
|
|
});
|
|
|
|
const recipients = await prisma.recipient.findMany({
|
|
where: {
|
|
document: documentWhereInput,
|
|
},
|
|
orderBy: {
|
|
id: 'asc',
|
|
},
|
|
});
|
|
|
|
return recipients;
|
|
};
|
|
|
|
export interface GetAllRecipientsByDocumentIdOptions {
|
|
documentId: number;
|
|
}
|
|
|
|
export const getAllRecipientsByDocumentId = async ({
|
|
documentId,
|
|
}: GetAllRecipientsByDocumentIdOptions) => {
|
|
const recipients = await prisma.recipient.findMany({
|
|
where: {
|
|
documentId,
|
|
},
|
|
select: {
|
|
role: true,
|
|
signingStatus: true,
|
|
},
|
|
orderBy: {
|
|
id: 'asc',
|
|
},
|
|
});
|
|
|
|
return recipients;
|
|
};
|