Skip to content

Commit

Permalink
Fixes to vehicleHistory
Browse files Browse the repository at this point in the history
  • Loading branch information
Delaney H committed Apr 15, 2024
1 parent 57eef8c commit f545fcd
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions frontend/src/pages/vehicle/VehicleHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand All @@ -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 (
<Container className="mt-5">
Expand All @@ -95,7 +96,7 @@ function VehicleHistory(props) {
{vehicleInfo ? (
<span onClick={() => 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}
</span>
) : (
<span style={{ color: '#644A77', fontWeight: 'normal' }}> Loading Vehicle Info...</span>
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));

Expand Down

0 comments on commit f545fcd

Please sign in to comment.