mirror of
https://github.com/documenso/documenso.git
synced 2025-11-16 09:41:35 +10:00
feat: add template meta for templates
Signed-off-by: Adithya Krishna <aadithya794@gmail.com>
This commit is contained in:
@ -0,0 +1,50 @@
|
||||
'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;
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user