Files
documenso/packages/lib/server-only/template-document-meta/upsert-template-document-meta.ts
Adithya Krishna cce0cdfbe2 feat: add template meta for templates
Signed-off-by: Adithya Krishna <aadithya794@gmail.com>
2024-04-18 17:47:50 +05:30

51 lines
974 B
TypeScript

'use server';
import { prisma } from '@documenso/prisma';
export type CreateTemplateDocumentMetaOptions = {
templateId: number;
subject?: string;
message?: string;
timezone?: string;
password?: string;
dateFormat?: string;
redirectUrl?: string;
};
export const upsertTemplateDocumentMeta = async ({
subject,
message,
timezone,
dateFormat,
templateId,
password,
redirectUrl,
}: CreateTemplateDocumentMetaOptions) => {
return await prisma.$transaction(async (tx) => {
const upsertedTemplateDocumentMeta = await tx.templateDocumentMeta.upsert({
where: {
templateId,
},
update: {
subject,
message,
timezone,
password,
dateFormat,
redirectUrl,
},
create: {
templateId,
subject,
message,
timezone,
password,
dateFormat,
redirectUrl,
},
});
return upsertedTemplateDocumentMeta;
});
};