diff options
Diffstat (limited to 'modern')
-rw-r--r-- | modern/src/DevicesList.js | 14 | ||||
-rw-r--r-- | modern/src/MainPage.js | 4 | ||||
-rw-r--r-- | modern/src/common/formatter.js | 9 |
3 files changed, 8 insertions, 19 deletions
diff --git a/modern/src/DevicesList.js b/modern/src/DevicesList.js index 3085552..b98956c 100644 --- a/modern/src/DevicesList.js +++ b/modern/src/DevicesList.js @@ -23,7 +23,7 @@ import LockOpenIcon from '@material-ui/icons/LockOpen'; import { devicesActions, uiActions } from './store'; import EditCollectionView from './EditCollectionView'; import { useEffectAsync } from './reactHelper'; -import { formatPosition, formatSpeed, formatDate, formatHours } from './common/formatter'; +import { formatPosition, formatSpeed, formatHours } from './common/formatter'; import { useAttributePreference } from './common/preferences'; import { getDevices, getFilteredDevices, getFilterTerm, getPosition } from './common/selectors'; import { useTranslation } from './LocalizationProvider'; @@ -72,18 +72,6 @@ const useStyles = makeStyles((theme) => ({ }, })); -const getStatusColor = (status) => { - switch (status) { - case 'online': - return 'green'; - case 'offline': - return 'red'; - case 'unknown': - default: - return 'gray'; - } -}; - const getBatteryStatus = (batteryLevel) => { if (batteryLevel >= 70) { return 'green'; diff --git a/modern/src/MainPage.js b/modern/src/MainPage.js index 374f132..e2d4626 100644 --- a/modern/src/MainPage.js +++ b/modern/src/MainPage.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useEffect } from 'react'; import { useHistory } from 'react-router-dom'; import { makeStyles, Paper, Toolbar, TextField, IconButton, Button, @@ -98,8 +98,6 @@ const MainPage = () => { const dispatch = useDispatch(); const t = useTranslation(); - const isComputer = useMediaQuery(theme.breakpoints.down('lg')); - const isTablet = useMediaQuery(theme.breakpoints.down('md')); const isPhone = useMediaQuery(theme.breakpoints.down('sm')); const isWide = useMediaQuery(theme.breakpoints.up('md')/* || theme.breakpoints.up('sm') || theme.breakpoints.up('xs')*/); diff --git a/modern/src/common/formatter.js b/modern/src/common/formatter.js index db0b7ff..f8a55da 100644 --- a/modern/src/common/formatter.js +++ b/modern/src/common/formatter.js @@ -4,9 +4,12 @@ export const formatBoolean = (value, t) => (value ? t('sharedYes') : t('sharedNo export const formatNumber = (value, precision = 1) => Number(value.toFixed(precision)); -export const formatDate = (value, format = 'YYYY-MM-DD HH:mm') => moment(value).format(format); +export const formatDate = (value, locale) => new Intl.DateTimeFormat(locale, { + dateStyle: 'medium', + timeStyle: 'short', +}).format(Date.parse(value)); -export const formatPosition = (value, key, t) => { +export const formatPosition = (value, key, t, locale = 'es') => { if (value != null && typeof value === 'object') { value = value[key]; } @@ -15,7 +18,7 @@ export const formatPosition = (value, key, t) => { case 'deviceTime': case 'serverTime': case 'eventTime': - return moment(value).format('LLL'); + return formatDate(value, locale); case 'latitude': case 'longitude': return value.toFixed(5); |