mirror of
https://github.com/documenso/documenso.git
synced 2025-11-16 01:32:06 +10:00
fix: refactor
This commit is contained in:
@ -47,7 +47,11 @@ export const createDocumentFromTemplate = async ({
|
|||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
Recipient: true,
|
Recipient: true,
|
||||||
Field: true,
|
Field: {
|
||||||
|
include: {
|
||||||
|
Recipient: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
templateDocumentData: true,
|
templateDocumentData: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -125,12 +129,10 @@ export const createDocumentFromTemplate = async ({
|
|||||||
|
|
||||||
await tx.field.createMany({
|
await tx.field.createMany({
|
||||||
data: template.Field.map((field) => {
|
data: template.Field.map((field) => {
|
||||||
const recipient = template.Recipient.find(
|
const documentRecipient = document.Recipient.find(
|
||||||
(recipient) => recipient.id === field.recipientId,
|
(recipient) => recipient.email === field.Recipient.email,
|
||||||
);
|
);
|
||||||
|
|
||||||
const documentRecipient = document.Recipient.find((doc) => doc.email === recipient?.email);
|
|
||||||
|
|
||||||
if (!documentRecipient) {
|
if (!documentRecipient) {
|
||||||
throw new Error('Recipient not found.');
|
throw new Error('Recipient not found.');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user