fix: Scheduled maintenance list not displaying schedules (#129) #148
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Relates to #129
Summary
The Schedules tab on the Maintenance page is always empty despite schedules existing in the database (e.g., 30 schedules created from manual OCR extraction). The UI components are fully implemented but the data query never executes.
Root Cause
MaintenancePage.tsx(line 20) callsuseMaintenanceRecords()without a vehicleId parameter:The schedules query in
useMaintenanceRecords.tshasenabled: !!vehicleId-- when vehicleId is undefined, the query never runs. The list stays empty.Additionally, the creation hook (
useCreateSchedulesFromExtraction) invalidates['maintenanceSchedules', vehicleId]with the actual vehicleId, but the page-level query uses['maintenanceSchedules', undefined]-- the keys don't match, so invalidation has no effect.Requirements
useMaintenanceRecords(vehicleId)useFuelLogs(vehicleId))Acceptance Criteria
feat: Scheduled maintenance list UI with CRUD and due status (#129)to fix: Scheduled maintenance list not displaying schedules (#129)Plan: Fix scheduled maintenance list not displaying schedules
Phase: Planning | Agent: Planner | Status: AWAITING_REVIEW
Root Cause Analysis
MaintenancePage.tsxandMaintenanceMobileScreen.tsxboth calluseMaintenanceRecords()without avehicleId. The hook's schedules query hasenabled: !!vehicleId, so it never executes. Records work because the hook falls back togetRecords()(all records), but schedules requirevehicleIdbecause the backend only hasGET /maintenance/schedules/vehicle/:vehicleId(no "get all schedules" endpoint).Fix Strategy
Add a vehicle selector to the Maintenance page (matching the FuelLogs pattern) and pass the selected vehicleId to the hook. This is a frontend-only fix -- no backend changes needed.
Milestone 1: Wire vehicleId into MaintenancePage and MaintenanceMobileScreen
Files to modify (3):
frontend/src/features/maintenance/pages/MaintenancePage.tsxselectedVehicleIdstate (useState)useVehicles()hook + MUI Select, matching the inline pattern already used in MaintenanceRecordForm)selectedVehicleIdtouseMaintenanceRecords(selectedVehicleId)selectedVehicleIdto forms as default vehicle (optional UX improvement)frontend/src/features/maintenance/mobile/MaintenanceMobileScreen.tsxfrontend/src/features/maintenance/hooks/useMaintenanceRecords.ts(verification only)vehicleId?: stringand passes it correctlyExpected Behavior After Fix
Out of Scope
Risk Assessment
Verdict: AWAITING_REVIEW | Next: User approval, then execution
Milestone 1: Wire vehicleId into MaintenancePage and MaintenanceMobileScreen
Phase: Execution | Agent: Developer | Status: PASS
Changes Made
frontend/src/features/maintenance/pages/MaintenancePage.tsxuseVehicles()hook andselectedVehicleIdstateselectedVehicleIdtouseMaintenanceRecords(selectedVehicleId || undefined)['maintenanceRecords', 'all']refetch key in delete handler to use broad['maintenanceRecords']prefixfrontend/src/features/maintenance/mobile/MaintenanceMobileScreen.tsxfrontend/src/features/maintenance/hooks/useMaintenanceRecords.ts(verified, no changes needed)vehicleId?: stringand gates schedules query onenabled: !!vehicleIdQuery Invalidation Alignment Verified
useMaintenanceRecordsmutations['maintenanceSchedules'](broad)useCreateSchedulesFromExtraction['maintenanceSchedules', vehicleId]['maintenanceRecords'](broad, fixed)Quality Checks
Commit
6bb2c57-fix: Wire vehicleId into maintenance page to display schedules (refs #148)Verdict: PASS | Next: PR creation and final review