Files
sign/packages/lib/server-only/recipient/get-recipients-for-template.ts

40 lines
735 B
TypeScript
Raw Normal View History

2023-10-06 22:54:24 +00:00
import { prisma } from '@documenso/prisma';
export interface GetRecipientsForTemplateOptions {
templateId: number;
userId: number;
teamId?: number;
2023-10-06 22:54:24 +00:00
}
export const getRecipientsForTemplate = async ({
templateId,
userId,
teamId,
2023-10-06 22:54:24 +00:00
}: GetRecipientsForTemplateOptions) => {
const recipients = await prisma.recipient.findMany({
where: {
templateId,
2025-01-13 13:41:53 +11:00
template: teamId
? {
2024-02-08 12:33:20 +11:00
team: {
id: teamId,
2024-02-08 12:33:20 +11:00
members: {
some: {
userId,
},
},
},
}
: {
userId,
teamId: null,
2024-02-08 12:33:20 +11:00
},
2023-10-06 22:54:24 +00:00
},
orderBy: {
id: 'asc',
},
});
return recipients;
};