From 4d6f6d5d027a4559c94c1532027b40c2bc2758a4 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:41:04 +0000 Subject: [PATCH] Apply patch [skip ci] --- routes/landlord/leases/index.tsx | 59 ++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 routes/landlord/leases/index.tsx diff --git a/routes/landlord/leases/index.tsx b/routes/landlord/leases/index.tsx new file mode 100644 index 0000000..3b6a6b7 --- /dev/null +++ b/routes/landlord/leases/index.tsx @@ -0,0 +1,59 @@ +import { define } from "../../../utils.ts"; +import LeasedHome from "../../../islands/LeasedHome.tsx"; +import { page } from "fresh"; +import { SessionCookie } from "../../auth/callback.ts"; +import WelcomeBar from "../../../islands/WelcomeBar/WelcomeBar.tsx"; +import { getAllProperties } from "../../../services/propertyService.ts"; +import { getLeasesByOwner } from "../../../services/leaseService.ts"; +import { createPublicId } from "../../../helpers.ts"; +import type { Lease, Property } from "../../../db/interfaces.ts"; + +export const handler = define.handlers({ + async GET(ctx) { + const stateData: SessionCookie = ctx.state.data; + if (!stateData?.user_id) { + return new Response("", { + status: 302, + headers: { Location: "/auth/login" }, + }); + } + + const ownerId = stateData.user_id; + let leases: Lease[] = []; + let properties: Property[] = []; + + leases = await getLeasesByOwner(ownerId); + properties = await getAllProperties(); + + const publicId = stateData.user_id + ? await createPublicId(stateData.user_id) + : ""; + + return page({ + stateData, + leases, + properties, + user_name: stateData.user_name, + isEncrypted: stateData.user_encrypted, + publicId, + stateId: ctx.state.stateId, + }); + }, +}); + +export default define.page( + ({ data }: { data: { stateData: SessionCookie; leases: Lease[]; properties: Property[]; user_name: string; isEncrypted: boolean; publicId: string; stateId: string } }) => ( +
+ +
+ +
+
+ ), +);