mirror of
https://github.com/documenso/documenso.git
synced 2025-11-16 09:41:35 +10:00
fix: enhancements
This commit is contained in:
@ -56,13 +56,13 @@ export const createDocumentFromTemplate = async ({
|
||||
throw new Error('Template not found.');
|
||||
}
|
||||
|
||||
if (recipients.length === 0 || recipients.length !== template.Recipient.length) {
|
||||
if (recipients.length !== template.Recipient.length) {
|
||||
throw new Error('Invalid number of recipients.');
|
||||
}
|
||||
|
||||
let finalRecipients: Pick<Recipient, 'name' | 'email' | 'role'>[] = [];
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(recipients[0], 'id')) {
|
||||
if (recipients.length > 0 && Object.prototype.hasOwnProperty.call(recipients[0], 'id')) {
|
||||
finalRecipients = template.Recipient.map((templateRecipient) => {
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
const foundRecipient = (recipients as RecipientWithId[]).find(
|
||||
|
||||
@ -66,7 +66,9 @@ export const templateRouter = router({
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
requestMetadata: extractNextApiRequestMetadata(ctx.req),
|
||||
}).catch(() => {
|
||||
}).catch((err) => {
|
||||
console.error(err);
|
||||
|
||||
throw new AppError('DOCUMENT_SEND_FAILED');
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user