remaining TODO.

This commit is contained in:
Nathan Anderson 2026-01-29 11:59:47 -06:00
parent 52439c1178
commit 336b469983

126
TODO.md
View File

@ -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: ## Remaining Development Tasks
- `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`
### 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 ### 2. Lease Finalization Logic (HIGH PRIORITY)
- [x] Created `POST /api/lease/approve` - Landlord approval - [ ] Implement complete lease activation on approval
- [x] Created `POST /api/lease/reject` - Landlord rejection - [ ] Ensure proper tenant_id linking when approved
- [x] Created `GET /api/lease/pending-approvals` - Landlord dashboard - [ ] Set up payment schedules and access rights
- [x] Extended `leaseService.ts` with approval functions: - [ ] Update property rental_status to 'occupied'
- `requestLeaseApproval()` - [ ] Create lease document generation
- `approveLease()`
- `rejectLease()`
- `getPendingApprovals()`
### 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 ### 4. Landlord Dashboard Approval Interface (MEDIUM PRIORITY)
- [x] Added status-based UI states: - [ ] Add approve/reject buttons to pending approval cards
- No lease: "Start Lease" button - [ ] Create approval modal with lease details
- Pending: "Pending Landlord Approval" - [ ] Add confirmation dialogs for approve/reject actions
- Approved: "Lease Approved - Continue" - [ ] Implement real-time updates after approval actions
- Rejected: "Lease Rejected" with contact info
- [x] Added progress indicator showing approval steps
- [x] Updated POST handler to call approval API
### 4. Landlord Service ✅ ### 5. Email Notification Implementation (MEDIUM PRIORITY)
- [ ] Complete email template implementation in notificationService
- [x] Added `getPendingLeaseApprovals()` function in `landlordService.ts` - [ ] Add email sending functionality for approval requests
- [ ] Implement landlord notification when approval needed
--- - [ ] Add tenant notification for approval/rejection outcomes
## 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
### 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:** **Tasks:**
- [ ] Create `routes/landlord/approvals/index.tsx` - [ ] Create `routes/landlord/approvals/index.tsx`