fix(06): correct clientName in agent notification email

This commit is contained in:
Chandler Copeland
2026-03-21 09:49:06 -06:00
parent 04e3d5cb54
commit 04c3720096

View File

@@ -3,7 +3,7 @@ import { NextRequest, NextResponse } from 'next/server';
import { verifySigningToken } from '@/lib/signing/token';
import { logAuditEvent } from '@/lib/signing/audit';
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 path from 'node:path';
import { embedSignatureInPdf } from '@/lib/signing/embed-signature';
@@ -229,12 +229,13 @@ export async function POST(
db.query.documents
.findFirst({
where: eq(documents.id, payload.documentId),
with: { client: { columns: { name: true } } },
columns: { name: true },
})
.then(async (freshDoc) => {
try {
await sendAgentNotificationEmail({
clientName: freshDoc?.name ?? 'Client',
clientName: (freshDoc as { client?: { name: string } } & typeof freshDoc)?.client?.name ?? 'Client',
documentName: freshDoc?.name ?? doc.name,
signedAt: now,
});