From 1b2d62ee9deb83b454b5c2f29a700eb3c75d01db Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 29 Jan 2026 19:09:09 +0000 Subject: [PATCH] Apply patch [skip ci] --- routes/api/lease/reject.ts | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/routes/api/lease/reject.ts b/routes/api/lease/reject.ts index 2770689..9d856af 100644 --- a/routes/api/lease/reject.ts +++ b/routes/api/lease/reject.ts @@ -85,21 +85,24 @@ export const handler = define.handlers({ } const rejectedLease = 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 sendLeaseRejected(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 sendLeaseRejected(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({