mirror of
https://github.com/documenso/documenso.git
synced 2025-11-22 04:31:39 +10:00
48 lines
920 B
TypeScript
48 lines
920 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
|
|
export interface GetFieldsForDocumentOptions {
|
|
documentId: number;
|
|
userId: string;
|
|
}
|
|
|
|
export type DocumentField = Awaited<ReturnType<typeof getFieldsForDocument>>[number];
|
|
|
|
export const getFieldsForDocument = async ({ documentId, userId }: GetFieldsForDocumentOptions) => {
|
|
const fields = await prisma.field.findMany({
|
|
where: {
|
|
documentId,
|
|
Document: {
|
|
OR: [
|
|
{
|
|
userId,
|
|
},
|
|
{
|
|
team: {
|
|
members: {
|
|
some: {
|
|
userId,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
},
|
|
include: {
|
|
Signature: true,
|
|
Recipient: {
|
|
select: {
|
|
name: true,
|
|
email: true,
|
|
signingStatus: true,
|
|
},
|
|
},
|
|
},
|
|
orderBy: {
|
|
id: 'asc',
|
|
},
|
|
});
|
|
|
|
return fields;
|
|
};
|