Apply patch [skip ci]
This commit is contained in:
parent
949c3830cd
commit
6f04b3dad5
@ -1,10 +1,12 @@
|
||||
// routes/api/lease/reject.ts
|
||||
import { define } from "../../../utils.ts";
|
||||
import { SessionCookie } from "../../auth/callback.ts";
|
||||
import { getLeaseById, rejectLease } from "../../../services/leaseService.ts";
|
||||
import { rejectLease, getLeaseById } from "../../../services/leaseService.ts";
|
||||
import { getUserById } from "../../../services/userService.ts";
|
||||
import { getPropertyById } from "../../../services/propertyService.ts";
|
||||
import { sendLeaseRejected } from "../../../services/notificationService.ts";
|
||||
import {
|
||||
sendLeaseRejected,
|
||||
} from "../../../services/notificationService.ts";
|
||||
|
||||
export const handler = define.handlers({
|
||||
async POST(ctx) {
|
||||
@ -83,29 +85,27 @@ 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 ?? undefined,
|
||||
});
|
||||
}
|
||||
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({
|
||||
success: true,
|
||||
lease: rejectedLease,
|
||||
lease: rejectedLease,
|
||||
}),
|
||||
{
|
||||
status: 200,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user