chore: template attachments

This commit is contained in:
Catalin Pit
2025-07-07 13:31:55 +03:00
parent 30b240cba2
commit e19da93ce2
19 changed files with 583 additions and 195 deletions

View File

@ -6,14 +6,12 @@ import { AppError } from '../../errors/app-error';
import { AppErrorCode } from '../../errors/app-error';
export type CreateAttachmentsOptions = {
documentId?: number;
templateId?: number;
documentId: number;
attachments: Pick<Attachment, 'id' | 'label' | 'url' | 'type'>[];
};
export const setDocumentAttachments = async ({
documentId,
templateId,
attachments,
}: CreateAttachmentsOptions) => {
const document = await prisma.document.findUnique({
@ -55,13 +53,11 @@ export const setDocumentAttachments = async ({
label: attachment.label,
url: attachment.url,
type: attachment.type,
templateId,
},
create: {
label: attachment.label,
url: attachment.url,
type: attachment.type,
templateId,
documentId,
},
});
@ -72,7 +68,6 @@ export const setDocumentAttachments = async ({
label: attachment.label,
url: attachment.url,
type: attachment.type,
templateId,
documentId,
},
});