feat: add frontend document-vehicle API client and hooks (refs #31)

- Update DocumentRecord interface to include sharedVehicleIds array
- Add optional sharedVehicleIds to Create/UpdateDocumentRequest types
- Add documentsApi.listByVehicle() method for fetching by vehicle
- Add documentsApi.addSharedVehicle() for linking vehicles
- Add documentsApi.removeVehicleFromDocument() for unlinking
- Add useDocumentsByVehicle() query hook with vehicle filter
- Add useAddSharedVehicle() mutation with optimistic updates
- Add useRemoveVehicleFromDocument() mutation with optimistic updates
- Ensure query invalidation includes both documents and documents-by-vehicle keys
- Update test mocks to include sharedVehicleIds field
- Fix optimistic update in useCreateDocument to include new fields

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Eric Gullickson
2026-01-14 19:31:03 -06:00
parent 5dbc17e28d
commit e558fdf8f9
5 changed files with 142 additions and 0 deletions

View File

@@ -30,6 +30,7 @@ describe('DocumentPreview', () => {
documentType: 'insurance',
title: 'Insurance Document',
contentType: 'application/pdf',
sharedVehicleIds: [],
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
};
@@ -41,6 +42,7 @@ describe('DocumentPreview', () => {
documentType: 'registration',
title: 'Registration Photo',
contentType: 'image/jpeg',
sharedVehicleIds: [],
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
};
@@ -52,6 +54,7 @@ describe('DocumentPreview', () => {
documentType: 'insurance',
title: 'Text Document',
contentType: 'text/plain',
sharedVehicleIds: [],
createdAt: '2024-01-01T00:00:00Z',
updatedAt: '2024-01-01T00:00:00Z',
};