diff --git a/src/components/CarUpdates/Deploy/index.jsx b/src/components/CarUpdates/Deploy/index.jsx index c3c721b..85bacfc 100644 --- a/src/components/CarUpdates/Deploy/index.jsx +++ b/src/components/CarUpdates/Deploy/index.jsx @@ -49,18 +49,12 @@ const MainForm = () => { const handleVehiclesChange = (event) => { setSelectedVehicles(event.target.value); }; - const getCarIDs = () => { - if (!selectedVehicles) return []; - return selectedVehicles.map((vin) => { - return vehicles.find((vehicle) => vehicle.vin === vin).id; - }); - }; const onSubmit = async (event) => { try { event.preventDefault(); const data = { package_id: parseInt(packageid), - car_ids: getCarIDs(), + vins: selectedVehicles, }; await createCarUpdates(data, token); setMessage( diff --git a/src/components/CarUpdates/Status/index.jsx b/src/components/CarUpdates/Status/index.jsx index e27d875..fba0758 100644 --- a/src/components/CarUpdates/Status/index.jsx +++ b/src/components/CarUpdates/Status/index.jsx @@ -96,7 +96,7 @@ const MainForm = () => { {carUpdates.map((row) => ( {row.id} - {`${row.car.vin} ${row.car.model} ${row.car.year}`} + {row.vin} {row.status} {LocalDateTimeString(row.created)} diff --git a/src/components/Cars/List/index.jsx b/src/components/Cars/List/index.jsx index b3012b0..b7f0623 100644 --- a/src/components/Cars/List/index.jsx +++ b/src/components/Cars/List/index.jsx @@ -65,7 +65,6 @@ const MainForm = () => { - ID VIN Model Year @@ -75,8 +74,7 @@ const MainForm = () => { {vehicles.map((row) => ( - - {row.id} + {row.vin} {row.model} {row.year} diff --git a/src/components/Contexts/UpdateContext.test.jsx b/src/components/Contexts/UpdateContext.test.jsx index a3a3ed7..c184b3f 100644 --- a/src/components/Contexts/UpdateContext.test.jsx +++ b/src/components/Contexts/UpdateContext.test.jsx @@ -222,7 +222,7 @@ describe("UpdatesContext", () => { data-testid="with-bad-data" onClick={async () => { result = await exec( - { package_id: 1, car_ids: [] }, + { package_id: 1, vins: [] }, TEST_AUTH_OBJECT ); }} @@ -233,7 +233,7 @@ describe("UpdatesContext", () => { result = await exec( { package_id: 1, - car_ids: [1, 2, 3], + vins: ["FISKER123", "FISKER124", "FISKER125"], }, TEST_AUTH_OBJECT ); @@ -284,7 +284,7 @@ describe("UpdatesContext", () => { checkState("false", "", { id: 1, package_id: 1, - car_ids: [1, 2, 3], + vins: ["FISKER123", "FISKER124", "FISKER125"], }); }); }); diff --git a/src/components/Contexts/UpdatesContext.jsx b/src/components/Contexts/UpdatesContext.jsx index 97bf99c..11e0734 100644 --- a/src/components/Contexts/UpdatesContext.jsx +++ b/src/components/Contexts/UpdatesContext.jsx @@ -125,7 +125,7 @@ const validateCreateCarUpdates = (data) => { throw new Error("Package id required"); } - if (!data.car_ids || data.car_ids.length === 0) { + if (!data.vins || data.vins.length === 0) { throw new Error("Car ids required"); } };