From 31d7007d6a199299e541a93477342e3eef73aa47 Mon Sep 17 00:00:00 2001 From: Ashutosh Bishnoi Date: Wed, 24 Mar 2021 10:40:31 +0530 Subject: Some more code improvements --- modern/src/reports/RouteReportPage.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'modern/src/reports/RouteReportPage.js') diff --git a/modern/src/reports/RouteReportPage.js b/modern/src/reports/RouteReportPage.js index 1c13a132..807207d8 100644 --- a/modern/src/reports/RouteReportPage.js +++ b/modern/src/reports/RouteReportPage.js @@ -1,7 +1,7 @@ import React, { useState } from 'react'; import { DataGrid } from '@material-ui/data-grid'; import t from '../common/localization'; -import { formatPosition, formatDistance } from '../common/formatter'; +import { formatPosition, formatDistance, formatSpeed, formatBoolean, formatDate, formatNumber } from '../common/formatter'; import ReportFilter from './ReportFilter'; import ReportLayoutPage from './ReportLayoutPage'; import { useAttributePreference } from '../common/preferences'; @@ -28,31 +28,32 @@ const Filter = ({ setItems }) => { const RouteReportPage = () => { const distanceUnit = useAttributePreference('distanceUnit'); + const speedUnit = useAttributePreference('speedUnit'); const columns = [{ headerName: t('positionFixTime'), field: 'fixTime', type: 'dateTime', flex: 1, - valueFormatter: ({ value }) => formatPosition(value, 'fixTime'), + valueFormatter: ({ value }) => formatDate(value), }, { headerName: t('positionLatitude'), field: 'latitude', type: 'number', flex: 1, - valueFormatter: ({ value }) => formatPosition(value, 'latitude'), + valueFormatter: ({ value }) => formatNumber(value, 5), }, { headerName: t('positionLongitude'), field: 'longitude', type: 'number', flex: 1, - valueFormatter: ({ value }) => formatPosition(value, 'longitude'), + valueFormatter: ({ value }) => formatNumber(value, 5), }, { headerName: t('positionSpeed'), field: 'speed', type: 'number', flex: 1, - valueFormatter: ({ value }) => formatPosition(value, 'speed'), + valueFormatter: ({ value }) => formatSpeed(value, speedUnit), }, { headerName: t('positionAddress'), field: 'address', @@ -65,7 +66,7 @@ const RouteReportPage = () => { type: 'boolean', flex: 1, valueGetter: ({ row }) => row.attributes.ignition, - valueFormatter: ({ value }) => value ? 'Yes' : 'No', + valueFormatter: ({ value }) => formatBoolean(value), }, { headerName: t('deviceTotalDistance'), field: 'totalDistance', -- cgit v1.2.3