fix(06): correct clientName in agent notification email
This commit is contained in:
@@ -3,7 +3,7 @@ import { NextRequest, NextResponse } from 'next/server';
|
|||||||
import { verifySigningToken } from '@/lib/signing/token';
|
import { verifySigningToken } from '@/lib/signing/token';
|
||||||
import { logAuditEvent } from '@/lib/signing/audit';
|
import { logAuditEvent } from '@/lib/signing/audit';
|
||||||
import { db } from '@/lib/db';
|
import { db } from '@/lib/db';
|
||||||
import { signingTokens, documents } from '@/lib/db/schema';
|
import { signingTokens, documents, clients } from '@/lib/db/schema';
|
||||||
import { eq, isNull, and } from 'drizzle-orm';
|
import { eq, isNull, and } from 'drizzle-orm';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { embedSignatureInPdf } from '@/lib/signing/embed-signature';
|
import { embedSignatureInPdf } from '@/lib/signing/embed-signature';
|
||||||
@@ -229,12 +229,13 @@ export async function POST(
|
|||||||
db.query.documents
|
db.query.documents
|
||||||
.findFirst({
|
.findFirst({
|
||||||
where: eq(documents.id, payload.documentId),
|
where: eq(documents.id, payload.documentId),
|
||||||
|
with: { client: { columns: { name: true } } },
|
||||||
columns: { name: true },
|
columns: { name: true },
|
||||||
})
|
})
|
||||||
.then(async (freshDoc) => {
|
.then(async (freshDoc) => {
|
||||||
try {
|
try {
|
||||||
await sendAgentNotificationEmail({
|
await sendAgentNotificationEmail({
|
||||||
clientName: freshDoc?.name ?? 'Client',
|
clientName: (freshDoc as { client?: { name: string } } & typeof freshDoc)?.client?.name ?? 'Client',
|
||||||
documentName: freshDoc?.name ?? doc.name,
|
documentName: freshDoc?.name ?? doc.name,
|
||||||
signedAt: now,
|
signedAt: now,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user