From 04c37200962c288e11bce362442f81c5a46ec48a Mon Sep 17 00:00:00 2001 From: Chandler Copeland Date: Sat, 21 Mar 2026 09:49:06 -0600 Subject: [PATCH] fix(06): correct clientName in agent notification email --- teressa-copeland-homes/src/app/api/sign/[token]/route.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/teressa-copeland-homes/src/app/api/sign/[token]/route.ts b/teressa-copeland-homes/src/app/api/sign/[token]/route.ts index 1560e00..6cb5da7 100644 --- a/teressa-copeland-homes/src/app/api/sign/[token]/route.ts +++ b/teressa-copeland-homes/src/app/api/sign/[token]/route.ts @@ -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, });