Car table update (#27)

This commit is contained in:
John Wu
2021-04-05 10:09:40 -07:00
committed by GitHub
parent 17f81822c0
commit 113cc97fea
5 changed files with 7 additions and 15 deletions

View File

@@ -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(

View File

@@ -96,7 +96,7 @@ const MainForm = () => {
{carUpdates.map((row) => (
<TableRow key={row.id}>
<TableCell align="center">{row.id}</TableCell>
<TableCell align="center">{`${row.car.vin} ${row.car.model} ${row.car.year}`}</TableCell>
<TableCell align="center">{row.vin}</TableCell>
<TableCell align="center">{row.status}</TableCell>
<TableCell align="center">
{LocalDateTimeString(row.created)}