# maintenance/

Maintenance record and schedule management UI. Supports manual schedule creation and batch creation from OCR-extracted maintenance data. Three categories: routine maintenance, repair, performance upgrade.

## Subdirectories

| Directory | What | When to read |
| --------- | ---- | ------------ |
| `api/` | Maintenance API endpoints | API integration |
| `components/` | Forms, lists, review screen, subtype selection | UI changes |
| `hooks/` | Data fetching, batch schedule creation from extraction | Business logic |
| `mobile/` | Mobile-specific maintenance layout | Mobile UI |
| `pages/` | MaintenancePage (tabs: records, schedules) | Page layout |
| `types/` | TypeScript type definitions (categories, subtypes, schedules) | Type changes |

## Key Files

| File | What | When to read |
| ---- | ---- | ------------ |
| `hooks/useCreateSchedulesFromExtraction.ts` | Batch-creates maintenance schedules from OCR extraction results, maps MaintenanceScheduleItem to CreateScheduleRequest | OCR-to-schedule creation flow |
| `components/MaintenanceScheduleReviewScreen.tsx` | Dialog for reviewing OCR-extracted maintenance items: checkboxes for selection, confidence indicators, inline editing, batch create action | Extraction review UI, item editing |
| `components/MaintenanceScheduleForm.tsx` | Form for manual schedule creation | Schedule creation UI |
| `components/MaintenanceRecordForm.tsx` | Form for manual record creation | Record creation UI |
| `components/MaintenanceSchedulesList.tsx` | Schedule list with edit/delete | Schedule display |
| `components/MaintenanceRecordsList.tsx` | Record list display | Record display |
| `components/SubtypeCheckboxGroup.tsx` | Multi-select checkbox group for maintenance subtypes (27 routine, repair, performance) | Subtype selection UI |
| `hooks/useMaintenanceRecords.ts` | CRUD operations for maintenance records and schedules | Data management |
| `types/maintenance.types.ts` | MaintenanceCategory, ScheduleType, ROUTINE_MAINTENANCE_SUBTYPES, MaintenanceSchedule | Type definitions, subtype constants |
| `components/MaintenanceScheduleReviewScreen.test.tsx` | Tests for extraction review screen | Test changes |

## Extraction Review Flow

```
ManualExtractionResult (from documents/ feature useManualExtraction)
    |
    v
MaintenanceScheduleReviewScreen
    - Displays extracted items with confidence scores
    - Checkboxes for select/deselect
    - Inline editing of service name, intervals, details
    - Touch targets >= 44px for mobile
    |
    v
useCreateSchedulesFromExtraction.mutate(selectedItems)
    |
    v
POST /api/maintenance/schedules (batch create)
    |
    v
Query invalidation -> MaintenanceSchedulesList refreshes
```
