Apply patch [skip ci]
This commit is contained in:
parent
949c3830cd
commit
6f04b3dad5
@ -1,10 +1,12 @@
|
|||||||
// routes/api/lease/reject.ts
|
// routes/api/lease/reject.ts
|
||||||
import { define } from "../../../utils.ts";
|
import { define } from "../../../utils.ts";
|
||||||
import { SessionCookie } from "../../auth/callback.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 { getUserById } from "../../../services/userService.ts";
|
||||||
import { getPropertyById } from "../../../services/propertyService.ts";
|
import { getPropertyById } from "../../../services/propertyService.ts";
|
||||||
import { sendLeaseRejected } from "../../../services/notificationService.ts";
|
import {
|
||||||
|
sendLeaseRejected,
|
||||||
|
} from "../../../services/notificationService.ts";
|
||||||
|
|
||||||
export const handler = define.handlers({
|
export const handler = define.handlers({
|
||||||
async POST(ctx) {
|
async POST(ctx) {
|
||||||
@ -83,8 +85,6 @@ export const handler = define.handlers({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const rejectedLease = result[0];
|
const rejectedLease = result[0];
|
||||||
|
|
||||||
if (lease.tenant_id) {
|
|
||||||
const tenant = await getUserById(lease.tenant_id);
|
const tenant = await getUserById(lease.tenant_id);
|
||||||
const landlord = await getUserById(user_id);
|
const landlord = await getUserById(user_id);
|
||||||
const property = lease.property_id
|
const property = lease.property_id
|
||||||
@ -98,14 +98,14 @@ export const handler = define.handlers({
|
|||||||
: lease.property_address || "Property",
|
: lease.property_address || "Property",
|
||||||
tenant_name: tenant?.name || "Tenant",
|
tenant_name: tenant?.name || "Tenant",
|
||||||
landlord_name: landlord?.name || "Landlord",
|
landlord_name: landlord?.name || "Landlord",
|
||||||
monthly_rent: property?.monthly_rent ?? lease.rent ?? undefined,
|
monthly_rent: property?.monthly_rent || lease.rent,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
return new Response(
|
return new Response(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
success: true,
|
success: true,
|
||||||
lease: rejectedLease,
|
lease: rejectedLease,
|
||||||
|
lease: rejectedLease,
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
status: 200,
|
status: 200,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user