From 67cad2a3bb2a7d496d2e481ee9520f430d48c33c Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 29 Jan 2026 19:08:53 +0000 Subject: [PATCH] Apply patch [skip ci] --- routes/api/lease/approve.ts | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/routes/api/lease/approve.ts b/routes/api/lease/approve.ts index 69129ec..b2f7000 100644 --- a/routes/api/lease/approve.ts +++ b/routes/api/lease/approve.ts @@ -83,21 +83,24 @@ export const handler = define.handlers({ } const approvedLease = result[0]; - const tenant = await getUserById(lease.tenant_id); - const landlord = await getUserById(user_id); - const property = lease.property_id - ? await getPropertyById(lease.property_id) - : null; + + if (lease.tenant_id) { + const tenant = await getUserById(lease.tenant_id); + const landlord = await getUserById(user_id); + const property = lease.property_id + ? await getPropertyById(lease.property_id) + : null; - await sendLeaseApproved(lease.tenant_id, { - lease_id: lease.id, - property_address: property?.address_1 - ? `${property.address_1}, ${property.city}, ${property.state}` - : lease.property_address || "Property", - tenant_name: tenant?.name || "Tenant", - landlord_name: landlord?.name || "Landlord", - monthly_rent: property?.monthly_rent || lease.rent, - }); + await sendLeaseApproved(lease.tenant_id, { + lease_id: lease.id, + property_address: property?.address_1 + ? `${property.address_1}, ${property.city}, ${property.state}` + : lease.property_address || "Property", + tenant_name: tenant?.name || "Tenant", + landlord_name: landlord?.name || "Landlord", + monthly_rent: property?.monthly_rent || lease.rent, + }); + } return new Response( JSON.stringify({