From 2110974542f2700b5d801a540eded8e850be04aa Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 21 Jun 2022 07:20:14 -0700 Subject: Fix hours and accumulators --- modern/src/settings/AccumulatorsPage.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'modern/src/settings') diff --git a/modern/src/settings/AccumulatorsPage.js b/modern/src/settings/AccumulatorsPage.js index 37c77d5a..500c4e4a 100644 --- a/modern/src/settings/AccumulatorsPage.js +++ b/modern/src/settings/AccumulatorsPage.js @@ -16,6 +16,8 @@ import { useTranslation } from '../common/components/LocalizationProvider'; import PageLayout from '../common/components/PageLayout'; import SettingsMenu from './components/SettingsMenu'; import { useCatch } from '../reactHelper'; +import { useAttributePreference } from '../common/util/preferences'; +import { distanceFromMeters, distanceToMeters, distanceUnitString } from '../common/util/converter'; const useStyles = makeStyles((theme) => ({ container: { @@ -43,6 +45,8 @@ const AccumulatorsPage = () => { const classes = useStyles(); const t = useTranslation(); + const distanceUnit = useAttributePreference('distanceUnit'); + const { deviceId } = useParams(); const position = useSelector((state) => state.positions.items[deviceId]); @@ -85,15 +89,15 @@ const AccumulatorsPage = () => { setItem({ ...item, hours: Number(event.target.value) })} + value={item.hours / 1000} + onChange={(event) => setItem({ ...item, hours: Number(event.target.value) * 1000 })} label={t('positionHours')} /> setItem({ ...item, totalDistance: Number(event.target.value) })} - label={t('deviceTotalDistance')} + value={distanceFromMeters(item.totalDistance, distanceUnit)} + onChange={(event) => setItem({ ...item, totalDistance: distanceToMeters(Number(event.target.value), distanceUnit) })} + label={`${t('deviceTotalDistance')} (${distanceUnitString(distanceUnit, t)})`} /> -- cgit v1.2.3