From f559ae8d2f9c4a9bc5f450faa749a8ce13645fdd Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 4 May 2022 17:12:00 -0700 Subject: Implement send commands --- modern/src/settings/AccumulatorsPage.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'modern/src/settings/AccumulatorsPage.js') diff --git a/modern/src/settings/AccumulatorsPage.js b/modern/src/settings/AccumulatorsPage.js index f592445d..3e98612a 100644 --- a/modern/src/settings/AccumulatorsPage.js +++ b/modern/src/settings/AccumulatorsPage.js @@ -29,23 +29,23 @@ const AccumulatorsPage = () => { const classes = useStyles(); const t = useTranslation(); - const { id } = useParams(); - const position = useSelector((state) => state.positions.items[id]); + const { deviceId } = useParams(); + const position = useSelector((state) => state.positions.items[deviceId]); const [item, setItem] = useState(); useEffect(() => { if (position) { setItem({ - deviceId: parseInt(id, 10), + deviceId: parseInt(deviceId, 10), hours: position.attributes.hours || 0, totalDistance: position.attributes.totalDistance || 0, }); } - }, [id, position]); + }, [deviceId, position]); const handleSave = async () => { - const response = await fetch(`/api/devices/${id}/accumulators`, { + const response = await fetch(`/api/devices/${deviceId}/accumulators`, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(item), -- cgit v1.2.3