From c27959f04598c78b3995e073032f3a6cd0102ccf Mon Sep 17 00:00:00 2001 From: Eric Gullickson <16152721+ericgullickson@users.noreply.github.com> Date: Wed, 31 Dec 2025 16:07:32 -0600 Subject: [PATCH] fix: edit buttons --- docs/E2E-TESTING.md | 10 +++ docs/PROMPTS.md | 6 +- frontend/src/App.tsx | 63 ++++++++++++++++++- .../vehicles/mobile/VehicleDetailMobile.tsx | 14 ++++- .../vehicles/pages/VehicleDetailPage.tsx | 17 ++++- .../features/vehicles/pages/VehiclesPage.tsx | 2 +- 6 files changed, 100 insertions(+), 12 deletions(-) create mode 100644 docs/E2E-TESTING.md diff --git a/docs/E2E-TESTING.md b/docs/E2E-TESTING.md new file mode 100644 index 0000000..702b9ed --- /dev/null +++ b/docs/E2E-TESTING.md @@ -0,0 +1,10 @@ + Test scenarios to verify: + + | Test | Year | VIN | License Plate | Expected | + |-------------------------|------|--------------------|---------------|---------------------------| + | 1. Edit bug fix | Any | null (existing) | "TEST-123" | Should save without error | + | 2. Modern + VIN only | 2020 | Valid 17-char | Empty | Should work | + | 3. Modern + plate only | 2020 | Empty | "ABC-123" | Should work | + | 4. Modern + neither | 2020 | Empty | Empty | Should fail validation | + | 5. Pre-1981 + neither | 1970 | Empty | Empty | Should work | + | 6. Pre-1981 + short VIN | 1965 | "ABC123" (6 chars) | Empty | Should work | \ No newline at end of file diff --git a/docs/PROMPTS.md b/docs/PROMPTS.md index a6d362b..f8a1464 100644 --- a/docs/PROMPTS.md +++ b/docs/PROMPTS.md @@ -30,10 +30,8 @@ You are a senior software engineer specializsing in NodeJS, Typescript, front en *** CHANGES TO IMPLEMENT *** - Research this code base and ask iterative questions to compile a complete plan. - We will pair troubleshoot this. Tell me what logs and things to run and I will -- There is a bug in the ability to add and edit vehicles -- Change it so the every vehicle older than 1981 does not have a 17 digit VIN requirement. -- Verify the edit logic. When I had a license plate but no VIN, it still said the VIN was required. - +- There is a bug in the vehicles screen +- The pencil icon on the vehicle cards does not take you to the edit screen. It does nothing. diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 36f79b0..05a1292 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -265,6 +265,50 @@ const AddVehicleScreen: React.FC = ({ onBack, onAdded }) ); }; +interface EditVehicleScreenProps { + vehicle: Vehicle; + onBack: () => void; + onUpdated: () => void; +} + +const EditVehicleScreen: React.FC = ({ vehicle, onBack, onUpdated }) => { + const queryClient = useQueryClient(); + + const handleUpdateVehicle = async (data: CreateVehicleRequest) => { + try { + const { vehiclesApi } = await import('./features/vehicles/api/vehicles.api'); + await vehiclesApi.update(vehicle.id, data); + queryClient.invalidateQueries({ queryKey: ['vehicles'] }); + onUpdated(); + } catch (error) { + console.error('Failed to update vehicle:', error); + } + }; + + return ( +
+ +
+
+

Edit Vehicle

+ +
+ +
+
+
+ ); +}; + function App() { const { isLoading, isAuthenticated, user } = useAuth0(); const location = useLocation(); @@ -440,6 +484,16 @@ function App() { navigateToVehicleSubScreen('list', undefined, { source: 'vehicle-added' }); }, [navigateToVehicleSubScreen]); + const handleEditVehicle = useCallback(() => { + if (selectedVehicle) { + navigateToVehicleSubScreen('edit', selectedVehicle.id, { source: 'vehicle-detail' }); + } + }, [navigateToVehicleSubScreen, selectedVehicle]); + + const handleVehicleUpdated = useCallback(() => { + navigateToVehicleSubScreen('detail', selectedVehicle?.id, { source: 'vehicle-updated' }); + }, [navigateToVehicleSubScreen, selectedVehicle]); + // Enhanced debug component const DebugInfo = () => ( @@ -602,11 +656,18 @@ function App() { {vehicleSubScreen === 'add' || showAddVehicle ? ( - ) : selectedVehicle && (vehicleSubScreen === 'detail') ? ( + ) : selectedVehicle && vehicleSubScreen === 'edit' ? ( + + ) : selectedVehicle && vehicleSubScreen === 'detail' ? ( navigateToScreen("Log Fuel")} + onEdit={handleEditVehicle} /> ) : ( void; onLogFuel?: () => void; + onEdit?: () => void; } const Section: React.FC<{ title: string; children: React.ReactNode }> = ({ @@ -33,7 +34,8 @@ const Section: React.FC<{ title: string; children: React.ReactNode }> = ({ export const VehicleDetailMobile: React.FC = ({ vehicle, onBack, - onLogFuel + onLogFuel, + onEdit }) => { const displayName = vehicle.nickname || [vehicle.year, vehicle.make, vehicle.model, vehicle.trimLevel].filter(Boolean).join(' ') || 'Vehicle'; @@ -168,9 +170,15 @@ export const VehicleDetailMobile: React.FC = ({ - - +