From 336b4699837d1f9de4ac469dbc07d661a0e17b9b Mon Sep 17 00:00:00 2001 From: Nathan Anderson Date: Thu, 29 Jan 2026 11:59:47 -0600 Subject: [PATCH] remaining TODO. --- TODO.md | 126 +++++++++++++++++++------------------------------------- 1 file changed, 43 insertions(+), 83 deletions(-) diff --git a/TODO.md b/TODO.md index 0a16e1c..a36e589 100644 --- a/TODO.md +++ b/TODO.md @@ -1,95 +1,55 @@ -# TODO - Lease Approval Workflow +# TODO - Lease Approval Implementation Plan -## Completed Components +## Current Status Analysis +Based on codebase review, significant progress has been made. Here's what's already implemented vs remaining tasks. -### 1. Database Schema ✅ +## Already Completed +- [x] **Database Schema** - Approval fields added to `leases` table (approval_status, timestamps, approved_by, rejection_reason) +- [x] **API Endpoints** - All 4 endpoints created: + - `POST /api/lease/request-approval` - Tenant initiates lease + - `POST /api/lease/approve` - Landlord approval + - `POST /api/lease/reject` - Landlord rejection + - `GET /api/lease/pending-approvals` - Landlord dashboard +- [x] **Tenant Invitation Page** - Updated with approval status UI, progress indicators, and status-based messaging +- [x] **Landlord Dashboard** - Added pending approvals section with `getPendingLeaseApprovals()` integration +- [x] **Notification Service** - Basic structure created for lease approval notifications -- [x] Added approval workflow fields to `leases` table: - - `approval_status` TEXT DEFAULT 'pending_approval' - - `approval_requested_at` BIGINT - - `approved_at` BIGINT - - `approved_by` TEXT REFERENCES users(id) - - `rejection_reason` TEXT -- [x] Created migration SQL file: `drizzle/0008_add_lease_approval_fields.sql` -- [x] Updated database interfaces in `db/schema.ts` +## Remaining Development Tasks -### 2. API Endpoints ✅ +### 1. Database Migration (HIGH PRIORITY) +- [ ] Create migration SQL file for approval schema changes +- [ ] Run migration to update database with new lease fields +- [ ] Verify database schema matches code expectations -- [x] Created `POST /api/lease/request-approval` - Tenant initiates lease -- [x] Created `POST /api/lease/approve` - Landlord approval -- [x] Created `POST /api/lease/reject` - Landlord rejection -- [x] Created `GET /api/lease/pending-approvals` - Landlord dashboard -- [x] Extended `leaseService.ts` with approval functions: - - `requestLeaseApproval()` - - `approveLease()` - - `rejectLease()` - - `getPendingApprovals()` +### 2. Lease Finalization Logic (HIGH PRIORITY) +- [ ] Implement complete lease activation on approval +- [ ] Ensure proper tenant_id linking when approved +- [ ] Set up payment schedules and access rights +- [ ] Update property rental_status to 'occupied' +- [ ] Create lease document generation -### 3. Tenant Invitation Page ✅ +### 3. Tenant Invite Status Checking (MEDIUM PRIORITY) +- [ ] Add lease status checking in GET handler of invite page +- [ ] Update UI to show correct status on page load +- [ ] Handle edge cases (multiple leases, expired invites) -- [x] Updated `/tenant/invite/[invite_id].tsx` to check lease status -- [x] Added status-based UI states: - - No lease: "Start Lease" button - - Pending: "Pending Landlord Approval" - - Approved: "Lease Approved - Continue" - - Rejected: "Lease Rejected" with contact info -- [x] Added progress indicator showing approval steps -- [x] Updated POST handler to call approval API +### 4. Landlord Dashboard Approval Interface (MEDIUM PRIORITY) +- [ ] Add approve/reject buttons to pending approval cards +- [ ] Create approval modal with lease details +- [ ] Add confirmation dialogs for approve/reject actions +- [ ] Implement real-time updates after approval actions -### 4. Landlord Service ✅ - -- [x] Added `getPendingLeaseApprovals()` function in `landlordService.ts` - ---- - -## Incomplete / Needs Work - -### 1. Notification Service ❌ (HIGH PRIORITY) - -**Status:** File does not exist - -**Tasks:** - -- [ ] Create `services/notificationService.ts` for centralized notifications -- [ ] Implement `sendLeaseApprovalRequest()` function -- [ ] Implement `sendLeaseApproved()` function -- [ ] Implement `sendLeaseRejected()` function -- [ ] Integrate with user `notification_preferences_json` system -- [ ] Follow `messageService.ts` pattern for E2E fixture support -- [ ] Add E2E fixture functions in `services/e2eFixtures.ts` - -**Integration Points:** - -- Call `sendLeaseApprovalRequest()` in `routes/api/lease/request-approval.ts` -- Call `sendLeaseApproved()` in `routes/api/lease/approve.ts` -- Call `sendLeaseRejected()` in `routes/api/lease/reject.ts` - -### 2. Landlord Dashboard Updates ⚠️ (HIGH PRIORITY) - -**Status:** Dashboard exists but missing "Pending Lease Approvals" section - -**Current State:** - -- Dashboard has "Pending Applications" section (for tenant applications) -- Dashboard does NOT have "Pending Lease Approvals" section -- `getPendingLeaseApprovals()` function exists in `landlordService.ts` but is - not used - -**Tasks:** - -- [ ] Add "Pending Lease Approvals" section to - `routes/landlord/dashboard/index.tsx` -- [ ] Call `getPendingLeaseApprovals()` from `landlordService.ts` -- [ ] Display approval cards with property/tenant details -- [ ] Include approve/reject buttons calling `/api/lease/approve` and - `/api/lease/reject` -- [ ] Use existing card styling pattern from dashboard -- [ ] Add navigation badge for pending approvals count - -### 3. Dedicated Approvals Page ❌ (MEDIUM PRIORITY) - -**Status:** Page does not exist +### 5. Email Notification Implementation (MEDIUM PRIORITY) +- [ ] Complete email template implementation in notificationService +- [ ] Add email sending functionality for approval requests +- [ ] Implement landlord notification when approval needed +- [ ] Add tenant notification for approval/rejection outcomes +### 6. Testing (LOW PRIORITY) +- [ ] Add unit tests for lease approval service functions +- [ ] Create integration tests for API endpoints +- [ ] Add E2E tests for complete approval workflow +- [ ] Test error handling and edge cases **Tasks:** - [ ] Create `routes/landlord/approvals/index.tsx`