From a85e8bd2d875fbb2328bd987e7d2d62e825f7ca9 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:22:20 +0000 Subject: [PATCH 01/29] Apply patch [skip ci] --- routes/landlord/dashboard/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/routes/landlord/dashboard/index.tsx b/routes/landlord/dashboard/index.tsx index 9bfc72d..ae03063 100644 --- a/routes/landlord/dashboard/index.tsx +++ b/routes/landlord/dashboard/index.tsx @@ -537,3 +537,4 @@ export default define.page( }, ); + From fc7b0e7c9ed08e622fd1fb826bd62c6a8a27e047 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:24:26 +0000 Subject: [PATCH 02/29] Apply patch [skip ci] --- routes/landlord/dashboard/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/routes/landlord/dashboard/index.tsx b/routes/landlord/dashboard/index.tsx index ae03063..a8bd196 100644 --- a/routes/landlord/dashboard/index.tsx +++ b/routes/landlord/dashboard/index.tsx @@ -538,3 +538,4 @@ export default define.page( ); + From a41f40924520599659bec060e941553f1f5dcd97 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:26:49 +0000 Subject: [PATCH 03/29] Apply patch [skip ci] --- routes/landlord/dashboard/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/routes/landlord/dashboard/index.tsx b/routes/landlord/dashboard/index.tsx index a8bd196..6585e9b 100644 --- a/routes/landlord/dashboard/index.tsx +++ b/routes/landlord/dashboard/index.tsx @@ -539,3 +539,4 @@ export default define.page( + From db534016ea9c296c2757ec86c92bd3eaa1366305 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:27:51 +0000 Subject: [PATCH 04/29] Apply patch [skip ci] --- routes/landlord/dashboard/index.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/routes/landlord/dashboard/index.tsx b/routes/landlord/dashboard/index.tsx index 6585e9b..fc733fc 100644 --- a/routes/landlord/dashboard/index.tsx +++ b/routes/landlord/dashboard/index.tsx @@ -536,7 +536,3 @@ export default define.page( ); }, ); - - - - From b19e8c4929314a21481d74a09914b24f37a8f127 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:35:03 +0000 Subject: [PATCH 05/29] Apply patch [skip ci] --- islands/LeasedHome.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/islands/LeasedHome.tsx b/islands/LeasedHome.tsx index 2e9fcc8..f024cff 100644 --- a/islands/LeasedHome.tsx +++ b/islands/LeasedHome.tsx @@ -147,3 +147,4 @@ export default function LeasedHome({ leases, properties }: LeasedHomeProps) { ); } + From 5b5672a74b8a466780aaadbf4cc2458e5b9b7ad7 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:35:50 +0000 Subject: [PATCH 06/29] Apply patch [skip ci] --- routes/landlord/dashboard/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/routes/landlord/dashboard/index.tsx b/routes/landlord/dashboard/index.tsx index fc733fc..9bfc72d 100644 --- a/routes/landlord/dashboard/index.tsx +++ b/routes/landlord/dashboard/index.tsx @@ -536,3 +536,4 @@ export default define.page( ); }, ); + 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 07/29] 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 } }) => ( +
+ +
+ +
+
+ ), +); From 8e9d23633da0a00ffdbc10eb4d372d2af3f27b39 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:45:09 +0000 Subject: [PATCH 08/29] Apply patch [skip ci] --- islands/LeasedHome.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/islands/LeasedHome.tsx b/islands/LeasedHome.tsx index f024cff..ee5df5d 100644 --- a/islands/LeasedHome.tsx +++ b/islands/LeasedHome.tsx @@ -148,3 +148,4 @@ export default function LeasedHome({ leases, properties }: LeasedHomeProps) { ); } + From d19d0657fe58e590e853df734d84606b6b2fd93f Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:45:33 +0000 Subject: [PATCH 09/29] Apply patch [skip ci] --- islands/LeasedHome.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/islands/LeasedHome.tsx b/islands/LeasedHome.tsx index ee5df5d..9fcb4f2 100644 --- a/islands/LeasedHome.tsx +++ b/islands/LeasedHome.tsx @@ -149,3 +149,4 @@ export default function LeasedHome({ leases, properties }: LeasedHomeProps) { } + From de156b55446fef609a85b678524fca9d73ea45ac Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:46:42 +0000 Subject: [PATCH 10/29] Apply patch [skip ci] --- islands/LeasedHome.tsx | 3 --- routes/landlord/dashboard/index.tsx | 1 - routes/landlord/leases/index.tsx | 19 +++++++++++++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/islands/LeasedHome.tsx b/islands/LeasedHome.tsx index 9fcb4f2..2e9fcc8 100644 --- a/islands/LeasedHome.tsx +++ b/islands/LeasedHome.tsx @@ -147,6 +147,3 @@ export default function LeasedHome({ leases, properties }: LeasedHomeProps) { ); } - - - diff --git a/routes/landlord/dashboard/index.tsx b/routes/landlord/dashboard/index.tsx index 9bfc72d..fc733fc 100644 --- a/routes/landlord/dashboard/index.tsx +++ b/routes/landlord/dashboard/index.tsx @@ -536,4 +536,3 @@ export default define.page( ); }, ); - diff --git a/routes/landlord/leases/index.tsx b/routes/landlord/leases/index.tsx index 3b6a6b7..ebf9986 100644 --- a/routes/landlord/leases/index.tsx +++ b/routes/landlord/leases/index.tsx @@ -42,7 +42,19 @@ export const handler = define.handlers({ }); export default define.page( - ({ data }: { data: { stateData: SessionCookie; leases: Lease[]; properties: Property[]; user_name: string; isEncrypted: boolean; publicId: string; stateId: string } }) => ( + ( + { data }: { + data: { + stateData: SessionCookie; + leases: Lease[]; + properties: Property[]; + user_name: string; + isEncrypted: boolean; + publicId: string; + stateId: string; + }; + }, + ) => (
- +
), From c4b9af04463118f9de1e8544e4656a282bdec7e1 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:50:43 +0000 Subject: [PATCH 11/29] Apply patch [skip ci] --- services/leaseService.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/services/leaseService.ts b/services/leaseService.ts index 394da6f..70cbc22 100644 --- a/services/leaseService.ts +++ b/services/leaseService.ts @@ -251,3 +251,4 @@ export async function getLeaseStatsByOwner(owner_id: string) { + From 6fe771444288593c2bdab8c2093a278e49ea02ae Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:52:04 +0000 Subject: [PATCH 12/29] Apply patch [skip ci] --- services/leaseService.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/services/leaseService.ts b/services/leaseService.ts index 70cbc22..9952396 100644 --- a/services/leaseService.ts +++ b/services/leaseService.ts @@ -252,3 +252,4 @@ export async function getLeaseStatsByOwner(owner_id: string) { + From 2b8aca8aace42e5d5b27b40fd017fef3dde3853a Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:52:44 +0000 Subject: [PATCH 13/29] Apply patch [skip ci] --- services/leaseService.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/services/leaseService.ts b/services/leaseService.ts index 9952396..d4a4663 100644 --- a/services/leaseService.ts +++ b/services/leaseService.ts @@ -253,3 +253,4 @@ export async function getLeaseStatsByOwner(owner_id: string) { + From c81d9a32e226e7d36c595645dd4158d806892271 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:53:25 +0000 Subject: [PATCH 14/29] Apply patch [skip ci] --- services/leaseService.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/services/leaseService.ts b/services/leaseService.ts index d4a4663..de604eb 100644 --- a/services/leaseService.ts +++ b/services/leaseService.ts @@ -254,3 +254,4 @@ export async function getLeaseStatsByOwner(owner_id: string) { + From 78f78ebf39ff1b07a01750dc3cdb66ca1d5975f3 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:53:40 +0000 Subject: [PATCH 15/29] Apply patch [skip ci] --- services/leaseService.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/services/leaseService.ts b/services/leaseService.ts index de604eb..d1c5496 100644 --- a/services/leaseService.ts +++ b/services/leaseService.ts @@ -255,3 +255,4 @@ export async function getLeaseStatsByOwner(owner_id: string) { + From 748998f4888b017935def15013aa8749d6a458bd Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:54:02 +0000 Subject: [PATCH 16/29] Apply patch [skip ci] --- services/leaseService.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/services/leaseService.ts b/services/leaseService.ts index d1c5496..cde2ab2 100644 --- a/services/leaseService.ts +++ b/services/leaseService.ts @@ -256,3 +256,4 @@ export async function getLeaseStatsByOwner(owner_id: string) { + From afb4d5c1be22de1c58076dd5ef4c5bf75d56193e Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:54:29 +0000 Subject: [PATCH 17/29] Apply patch [skip ci] --- services/leaseService.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/services/leaseService.ts b/services/leaseService.ts index cde2ab2..e3223b8 100644 --- a/services/leaseService.ts +++ b/services/leaseService.ts @@ -257,3 +257,4 @@ export async function getLeaseStatsByOwner(owner_id: string) { + From b3b6480ea07c28bfbb6e895b15772987afd32cbd Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:55:06 +0000 Subject: [PATCH 18/29] Apply patch [skip ci] --- services/leaseService.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/services/leaseService.ts b/services/leaseService.ts index e3223b8..88b7387 100644 --- a/services/leaseService.ts +++ b/services/leaseService.ts @@ -258,3 +258,4 @@ export async function getLeaseStatsByOwner(owner_id: string) { + From e445242caf00e9af3d51297d50c38b31e2ac99ec Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:55:25 +0000 Subject: [PATCH 19/29] Apply patch [skip ci] --- services/leaseService.ts | 51 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/services/leaseService.ts b/services/leaseService.ts index 88b7387..3e93174 100644 --- a/services/leaseService.ts +++ b/services/leaseService.ts @@ -3,7 +3,7 @@ import { and, eq } from "drizzle-orm"; import { db } from "../db/db.ts"; -import { leases } from "../db/schema.ts"; +import { leases, tenant_invites } from "../db/schema.ts"; import { Lease } from "../db/interfaces.ts"; import { getE2ELeaseById, @@ -259,3 +259,52 @@ export async function getLeaseStatsByOwner(owner_id: string) { + + +/** + * Link a lease to a tenant invite. If an inviteId is provided, update that + * tenant_invites row to reference this lease. Otherwise attempt to find an + * existing invite by the lease's property and owner and attach the lease_id + * there; if none exists, create a new tenant_invites row linking to the lease. + */ +export async function inviteLease(lease_id: string, inviteId?: string) { + // If an explicit inviteId was provided, update that invite record + if (inviteId) { + const now = Date.now(); + return await db.update(tenant_invites) + .set({ lease_id, updated_on: now }) + .where(eq(tenant_invites.id, inviteId)) + .returning(); + } + + // Otherwise derive the property and landlord from the lease + const lease = await getLeaseById(lease_id); + if (!lease) return null; + + const existing = await db.select().from(tenant_invites).where( + and( + eq(tenant_invites.property_id, lease.property_id), + eq(tenant_invites.landlord_id, lease.owner_id), + ), + ); + + const now = Date.now(); + if (existing.length > 0) { + return await db.update(tenant_invites) + .set({ lease_id, updated_on: now }) + .where(eq(tenant_invites.id, existing[0].id)) + .returning(); + } + + // Create a new invite linking to this lease + return await db.insert(tenant_invites).values({ + id: crypto.randomUUID(), + landlord_id: lease.owner_id, + property_id: lease.property_id, + lease_id, + available_on: null, + invited_emails: JSON.stringify([]), + created_on: now, + updated_on: now, + }).returning(); +} From b7f773008dca146a09f48994eb89d633d211a023 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:55:47 +0000 Subject: [PATCH 20/29] Apply patch [skip ci] --- services/leaseService.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/services/leaseService.ts b/services/leaseService.ts index 3e93174..ad167d3 100644 --- a/services/leaseService.ts +++ b/services/leaseService.ts @@ -308,3 +308,4 @@ export async function inviteLease(lease_id: string, inviteId?: string) { updated_on: now, }).returning(); } + From 8fa91e1cf823662c94efb1a57bfd62df21084956 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:56:06 +0000 Subject: [PATCH 21/29] Apply patch [skip ci] --- services/leaseService.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/services/leaseService.ts b/services/leaseService.ts index ad167d3..cf60cbc 100644 --- a/services/leaseService.ts +++ b/services/leaseService.ts @@ -309,3 +309,4 @@ export async function inviteLease(lease_id: string, inviteId?: string) { }).returning(); } + From 3180d289d8fa3d020f657b583b0e3ce2daee9f8b Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:57:13 +0000 Subject: [PATCH 22/29] Apply patch [skip ci] --- db/schema.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/db/schema.ts b/db/schema.ts index 0fe7a6d..a41d7c4 100755 --- a/db/schema.ts +++ b/db/schema.ts @@ -388,3 +388,4 @@ export const brain_question_progress = pgTable("brain_question_progress", { created_on: bigint("created_on", { mode: "number" }), updated_on: bigint("updated_on", { mode: "number" }), }); + From 88ede76395ba2808ab257f9c4155ef12c96f6b73 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:58:12 +0000 Subject: [PATCH 23/29] Apply patch [skip ci] --- db/schema.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/db/schema.ts b/db/schema.ts index a41d7c4..6be7d12 100755 --- a/db/schema.ts +++ b/db/schema.ts @@ -389,3 +389,4 @@ export const brain_question_progress = pgTable("brain_question_progress", { updated_on: bigint("updated_on", { mode: "number" }), }); + From e4accc856c3df1b9812bdb87c02641f777ad4890 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 17:59:08 +0000 Subject: [PATCH 24/29] Apply patch [skip ci] --- db/schema.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/db/schema.ts b/db/schema.ts index 6be7d12..bf3193f 100755 --- a/db/schema.ts +++ b/db/schema.ts @@ -390,3 +390,4 @@ export const brain_question_progress = pgTable("brain_question_progress", { }); + From aaf58ef4b526f600a19cdb113c9f46a14a4c1204 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 18:00:26 +0000 Subject: [PATCH 25/29] Apply patch [skip ci] --- db/schema.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/db/schema.ts b/db/schema.ts index bf3193f..7bc121d 100755 --- a/db/schema.ts +++ b/db/schema.ts @@ -391,3 +391,4 @@ export const brain_question_progress = pgTable("brain_question_progress", { + From fd2d059e9c2f411e4095b5325a16ef82c9ed13c4 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 18:01:14 +0000 Subject: [PATCH 26/29] Apply patch [skip ci] --- db/schema.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/db/schema.ts b/db/schema.ts index 7bc121d..89d331b 100755 --- a/db/schema.ts +++ b/db/schema.ts @@ -392,3 +392,4 @@ export const brain_question_progress = pgTable("brain_question_progress", { + From b509f639320fe7d596559d5b9d35d2a5c876b668 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 18:01:41 +0000 Subject: [PATCH 27/29] Apply patch [skip ci] --- db/schema.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/db/schema.ts b/db/schema.ts index 89d331b..604397d 100755 --- a/db/schema.ts +++ b/db/schema.ts @@ -393,3 +393,4 @@ export const brain_question_progress = pgTable("brain_question_progress", { + From 173a27e40c88b5512067590b4f7bf44f2e1ff08b Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 18:02:03 +0000 Subject: [PATCH 28/29] Apply patch [skip ci] --- db/schema.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/db/schema.ts b/db/schema.ts index 604397d..2b3f17d 100755 --- a/db/schema.ts +++ b/db/schema.ts @@ -394,3 +394,4 @@ export const brain_question_progress = pgTable("brain_question_progress", { + From 261c6c283d52671d25b67236f9819099bb681f7e Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 18:03:06 +0000 Subject: [PATCH 29/29] Apply patch [skip ci] --- db/schema.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/db/schema.ts b/db/schema.ts index 2b3f17d..c2568a7 100755 --- a/db/schema.ts +++ b/db/schema.ts @@ -395,3 +395,4 @@ export const brain_question_progress = pgTable("brain_question_progress", { +