fix: external id null for documents created from templates (#1362)

This commit is contained in:
Ephraim Duncan
2024-10-08 10:45:16 +00:00
committed by GitHub
parent e40f47a73c
commit cd3d9b701b
3 changed files with 9 additions and 6 deletions

View File

@ -1,8 +1,9 @@
import { nanoid } from '@documenso/lib/universal/id'; import { nanoid } from '@documenso/lib/universal/id';
import { prisma } from '@documenso/prisma'; import { prisma } from '@documenso/prisma';
import type { DocumentSigningOrder, Field } from '@documenso/prisma/client';
import { import {
DocumentSigningOrder,
DocumentSource, DocumentSource,
type Field,
type Recipient, type Recipient,
RecipientRole, RecipientRole,
SendStatus, SendStatus,
@ -153,7 +154,7 @@ export const createDocumentFromTemplate = async ({
const document = await tx.document.create({ const document = await tx.document.create({
data: { data: {
source: DocumentSource.TEMPLATE, source: DocumentSource.TEMPLATE,
externalId, externalId: externalId || template.externalId,
templateId: template.id, templateId: template.id,
userId, userId,
teamId: template.teamId, teamId: template.teamId,
@ -172,7 +173,9 @@ export const createDocumentFromTemplate = async ({
dateFormat: override?.dateFormat || template.templateMeta?.dateFormat, dateFormat: override?.dateFormat || template.templateMeta?.dateFormat,
redirectUrl: override?.redirectUrl || template.templateMeta?.redirectUrl, redirectUrl: override?.redirectUrl || template.templateMeta?.redirectUrl,
signingOrder: signingOrder:
override?.signingOrder || template.templateMeta?.signingOrder || undefined, override?.signingOrder ||
template.templateMeta?.signingOrder ||
DocumentSigningOrder.PARALLEL,
}, },
}, },
Recipient: { Recipient: {

View File

@ -100,7 +100,7 @@ export const updateTemplateSettings = async ({
}, },
data: { data: {
title: data.title, title: data.title,
externalId: data.externalId || null, externalId: data.externalId,
type: data.type, type: data.type,
publicDescription: data.publicDescription, publicDescription: data.publicDescription,
publicTitle: data.publicTitle, publicTitle: data.publicTitle,

View File

@ -101,7 +101,7 @@ export const templateRouter = router({
.input(ZCreateDocumentFromTemplateMutationSchema) .input(ZCreateDocumentFromTemplateMutationSchema)
.mutation(async ({ input, ctx }) => { .mutation(async ({ input, ctx }) => {
try { try {
const { templateId, teamId } = input; const { templateId, teamId, recipients } = input;
const limits = await getServerLimits({ email: ctx.user.email, teamId }); const limits = await getServerLimits({ email: ctx.user.email, teamId });
@ -115,7 +115,7 @@ export const templateRouter = router({
templateId, templateId,
teamId, teamId,
userId: ctx.user.id, userId: ctx.user.id,
recipients: input.recipients, recipients,
requestMetadata, requestMetadata,
}); });