diff options
Diffstat (limited to 'modern/src/settings/AccumulatorsPage.js')
-rw-r--r-- | modern/src/settings/AccumulatorsPage.js | 14 |
1 files changed, 9 insertions, 5 deletions
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 = () => { <AccordionDetails className={classes.details}> <TextField type="number" - value={item.hours} - onChange={(event) => setItem({ ...item, hours: Number(event.target.value) })} + value={item.hours / 1000} + onChange={(event) => setItem({ ...item, hours: Number(event.target.value) * 1000 })} label={t('positionHours')} /> <TextField type="number" - value={item.totalDistance} - onChange={(event) => 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)})`} /> </AccordionDetails> </Accordion> |