From f545fcd49be1f05bc733f947dda49b464aa9e3bb Mon Sep 17 00:00:00 2001 From: Delaney H Date: Mon, 15 Apr 2024 17:22:55 -0230 Subject: [PATCH] Fixes to vehicleHistory --- frontend/src/pages/vehicle/VehicleHistory.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/frontend/src/pages/vehicle/VehicleHistory.js b/frontend/src/pages/vehicle/VehicleHistory.js index cf77be1..dfbd11d 100644 --- a/frontend/src/pages/vehicle/VehicleHistory.js +++ b/frontend/src/pages/vehicle/VehicleHistory.js @@ -53,8 +53,9 @@ function VehicleHistory(props) { headers: myHeaders, redirect: 'follow' }; - fetch(`/api/get-vehicle-info?configId=${configId}`, reqOptions) + fetch(`/api/get-vehicle-info?config_id=${configId}`, reqOptions) .then((res) => { + console.log('RES ' + res); if (!res.ok) { throw new Error('Network response was not ok'); } @@ -66,21 +67,21 @@ function VehicleHistory(props) { .catch((error) => { console.error('There has been a problem with your fetch operation:', error); }); - fetch(`/api/get-vehicle-history?configId=${configId}`, reqOptions) + fetch(`/api/get-vehicle-history?config_id=${configId}`, reqOptions) .then((res) => { if (!res.ok) { throw new Error('Network response was not ok'); } return res.json(); }) - .then((maintenanceData) => { - setMaintenance(maintenanceData[0]); + .then((maintenance) => { + setMaintenance(maintenance[0]); setLoading(false); }) .catch((error) => { console.error('There has been a problem with your fetch operation:', error); }); - }, [refreshData]); + }, []); return ( @@ -95,7 +96,7 @@ function VehicleHistory(props) { {vehicleInfo ? ( navigate(`/garage/vehicle-info/${configId}`, {state: {configId}})} style={{ cursor: 'pointer', color: '#644A77', fontWeight: 'bold' }}> - {vehicleInfo.year} {vehicleInfo.make} {vehicleInfo.model} + {vehicleInfo.message.year} {vehicleInfo.message.make} {vehicleInfo.message.model} ) : ( Loading Vehicle Info... @@ -203,7 +204,7 @@ function UpdateMaintenanceHistory(props) { redirect: 'follow' }; - fetch(`/api/update-maintenance-history?configId=${props.configId}`, reqOptions) + fetch(`/api/update-maintenance-history?config_id=${props.configId}`, reqOptions) .then((res) => res.json()) .then((result) => { console.log(result); @@ -304,11 +305,10 @@ function DeleteMaintenanceHistory(props) { redirect: "follow" }; - fetch(`/api/delete-maintenance-history?configId=${props.configId}`, reqOptions) + fetch(`/api/delete-maintenance-history?config_id=${props.configId}`, reqOptions) .then((response) => response.text()) .then((result) => { - console.log(result); - props.setRefreshData(!props.refreshData); + window.location.reload(); }) .catch((error) => console.error(error));