Apply patch [skip ci]

This commit is contained in:
open-swe-dev-andrinoid[bot] 2026-01-29 19:07:33 +00:00 committed by Nathan Anderson
parent d9c3b8ced3
commit 949c3830cd

View File

@ -4,7 +4,9 @@ import { SessionCookie } from "../../auth/callback.ts";
import { approveLease, getLeaseById } from "../../../services/leaseService.ts"; import { approveLease, getLeaseById } from "../../../services/leaseService.ts";
import { getUserById } from "../../../services/userService.ts"; import { getUserById } from "../../../services/userService.ts";
import { getPropertyById } from "../../../services/propertyService.ts"; import { getPropertyById } from "../../../services/propertyService.ts";
import { sendLeaseApproved } from "../../../services/notificationService.ts"; import {
sendLeaseApproved,
} from "../../../services/notificationService.ts";
export const handler = define.handlers({ export const handler = define.handlers({
async POST(ctx) { async POST(ctx) {
@ -81,29 +83,27 @@ export const handler = define.handlers({
} }
const approvedLease = result[0]; 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) { await sendLeaseApproved(lease.tenant_id, {
const tenant = await getUserById(lease.tenant_id); lease_id: lease.id,
const landlord = await getUserById(user_id); property_address: property?.address_1
const property = lease.property_id ? `${property.address_1}, ${property.city}, ${property.state}`
? await getPropertyById(lease.property_id) : lease.property_address || "Property",
: null; tenant_name: tenant?.name || "Tenant",
landlord_name: landlord?.name || "Landlord",
await sendLeaseApproved(lease.tenant_id, { monthly_rent: property?.monthly_rent || lease.rent,
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 ?? undefined,
});
}
return new Response( return new Response(
JSON.stringify({ JSON.stringify({
success: true, success: true,
lease: approvedLease, lease: approvedLease,
lease: approvedLease,
}), }),
{ {
status: 200, status: 200,