From 336c00ac843da828728be7c5e1333d176f41fe51 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 1 May 2022 17:33:14 -0700 Subject: Proper course formatting --- modern/src/common/formatter.js | 5 +++++ modern/src/map/StatusCard.js | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'modern') 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 ? : } - + -- cgit v1.2.3