diff options
-rw-r--r-- | modern/src/common/formatter.js | 5 | ||||
-rw-r--r-- | modern/src/map/StatusCard.js | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/modern/src/common/formatter.js b/modern/src/common/formatter.js index 6968deb7..fed29a9d 100644 --- a/modern/src/common/formatter.js +++ b/modern/src/common/formatter.js @@ -43,6 +43,11 @@ export const formatPosition = (value, key, t) => { } }; +export const formatCourse = (value) => { + const courseValues = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW']; + return courseValues[Math.floor(value / 45)]; +}; + export const formatDistance = (value, unit, t) => { switch (unit) { case 'mi': diff --git a/modern/src/map/StatusCard.js b/modern/src/map/StatusCard.js index 8b71913a..38d8833f 100644 --- a/modern/src/map/StatusCard.js +++ b/modern/src/map/StatusCard.js @@ -12,7 +12,7 @@ import DeleteIcon from '@material-ui/icons/Delete'; import { useTranslation } from '../LocalizationProvider'; import { - formatDistance, formatPosition, formatSpeed, formatStatus, + formatCourse, formatDistance, formatSpeed, formatStatus, } from '../common/formatter'; import RemoveDialog from '../RemoveDialog'; import { useAttributePreference } from '../common/preferences'; @@ -99,7 +99,7 @@ const StatusCard = ({ deviceId, onClose }) => { {position.attributes.odometer ? <StatusRow name={t('positionOdometer')} value={formatDistance(position.attributes.odometer, distanceUnit, t)} /> : <StatusRow name={t('deviceTotalDistance')} value={formatDistance(position.attributes.totalDistance, distanceUnit, t)} />} - <StatusRow name={t('positionCourse')} value={formatPosition(position.course, 'course', t)} /> + <StatusRow name={t('positionCourse')} value={formatCourse(position.course)} /> </TableBody> </Table> </TableContainer> |