aboutsummaryrefslogtreecommitdiff
path: root/modern/src/settings
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-21 07:20:14 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-21 07:20:14 -0700
commit2110974542f2700b5d801a540eded8e850be04aa (patch)
tree677886959b0cdb56ad3cee95966649e695edafd9 /modern/src/settings
parentadad08583e7829ce004388d949b8829cb7f92065 (diff)
downloadtrackermap-web-2110974542f2700b5d801a540eded8e850be04aa.tar.gz
trackermap-web-2110974542f2700b5d801a540eded8e850be04aa.tar.bz2
trackermap-web-2110974542f2700b5d801a540eded8e850be04aa.zip
Fix hours and accumulators
Diffstat (limited to 'modern/src/settings')
-rw-r--r--modern/src/settings/AccumulatorsPage.js14
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>