mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
feat: templates
This commit is contained in:
committed by
Mythie
parent
6d34ebd91b
commit
31a9127c9e
@ -0,0 +1,32 @@
|
||||
'use server';
|
||||
|
||||
import { getRequiredServerComponentSession } from '@documenso/lib/next-auth/get-server-session';
|
||||
import { setFieldsForTemplate } from '@documenso/lib/server-only/field/set-fields-for-template';
|
||||
import { TAddTemplateFieldsFormSchema } from '@documenso/ui/primitives/template-flow/add-template-fields.types';
|
||||
|
||||
export type AddTemplateFieldsActionInput = TAddTemplateFieldsFormSchema & {
|
||||
templateId: number;
|
||||
};
|
||||
|
||||
export const addTemplateFields = async ({ templateId, fields }: AddTemplateFieldsActionInput) => {
|
||||
'use server';
|
||||
|
||||
const { user } = await getRequiredServerComponentSession();
|
||||
|
||||
await setFieldsForTemplate({
|
||||
userId: user.id,
|
||||
templateId,
|
||||
fields: fields.map((field) => ({
|
||||
id: field.nativeId,
|
||||
signerEmail: field.signerEmail,
|
||||
signerId: field.signerId,
|
||||
signerToken: field.signerToken,
|
||||
type: field.type,
|
||||
pageNumber: field.pageNumber,
|
||||
pageX: field.pageX,
|
||||
pageY: field.pageY,
|
||||
pageWidth: field.pageWidth,
|
||||
pageHeight: field.pageHeight,
|
||||
})),
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user