From e7245fc142f6aa14e70036c0056c498971944cf9 Mon Sep 17 00:00:00 2001 From: Ashutosh Bishnoi Date: Tue, 6 Apr 2021 11:43:39 +0530 Subject: summary report data-grid conversion --- modern/src/reports/SummaryReportPage.js | 92 ++++++++++++++++++++++----------- modern/src/reports/TripReportPage.js | 2 +- 2 files changed, 62 insertions(+), 32 deletions(-) (limited to 'modern/src') diff --git a/modern/src/reports/SummaryReportPage.js b/modern/src/reports/SummaryReportPage.js index 5cfd857d..2af7d3b0 100644 --- a/modern/src/reports/SummaryReportPage.js +++ b/modern/src/reports/SummaryReportPage.js @@ -1,5 +1,6 @@ import React, { useState } from 'react'; -import { TableContainer, Table, TableRow, TableCell, TableHead, TableBody, Paper, FormControlLabel, Checkbox } from '@material-ui/core'; +import { DataGrid } from '@material-ui/data-grid'; +import { FormControlLabel, Checkbox } from '@material-ui/core'; import t from '../common/localization'; import { formatDistance, formatHours, formatDate, formatSpeed, formatVolume } from '../common/formatter'; import ReportFilter from './ReportFilter'; @@ -38,40 +39,69 @@ const SummaryReportPage = () => { const distanceUnit = useAttributePreference('distanceUnit'); const speedUnit = useAttributePreference('speedUnit'); + const volumeUnit = useAttributePreference('volumeUnit'); + const [items, setItems] = useState([]); + + const columns = [{ + headerName: t('reportStartDate'), + field: 'startTime', + type: 'dateTime', + flex: 1, + valueFormatter: ({ value }) => formatDate(value, 'YYYY-MM-DD'), + }, { + headerName: t('sharedDistance'), + field: 'distance', + type: 'number', + flex: 1, + valueFormatter: ({ value }) => formatDistance(value, distanceUnit), + }, { + headerName: t('reportStartOdometer'), + field: 'startOdometer', + type: 'number', + flex: 1, + valueFormatter: ({ value }) => formatDistance(value, distanceUnit), + }, { + headerName: t('reportEndOdometer'), + field: 'endOdometer', + type: 'number', + flex: 1, + valueFormatter: ({ value }) => formatDistance(value, distanceUnit), + }, { + headerName: t('reportAverageSpeed'), + field: 'averageSpeed', + type: 'number', + flex: 1, + valueFormatter: ({ value }) => formatSpeed(value, speedUnit), + }, { + headerName: t('reportMaximumSpeed'), + field: 'maxSpeed', + type: 'number', + flex: 1, + valueFormatter: ({ value }) => formatSpeed(value, speedUnit), + }, { + headerName: t('reportEngineHours'), + field: 'engineHours', + type: 'string', + flex: 1, + valueFormatter: ({ value }) => formatHours(value), + }, { + headerName: t('reportSpentFuel'), + field: 'spentFuel', + type: 'number', + flex: 1, + hide: true, + valueFormatter: ({ value }) => formatVolume(value, volumeUnit), + }] return ( }> - - - - - {t('reportStartDate')} - {t('sharedDistance')} - {t('reportStartOdometer')} - {t('reportEndOdometer')} - {t('reportAverageSpeed')} - {t('reportMaximumSpeed')} - {t('reportEngineHours')} - {t('reportSpentFuel')} - - - - {items.map((item) => ( - - {formatDate(item.startTime, 'YYYY-MM-DD')} - {formatDistance(item.distance, distanceUnit)} - {formatDistance(item.startOdometer, distanceUnit)} - {formatDistance(item.endOdometer, distanceUnit)} - {formatSpeed(item.averageSpeed, speedUnit)} - {formatSpeed(item.maxSpeed, speedUnit)} - {formatHours(item.engineHours)} - {formatVolume(item.spentFuel)} - - ))} - -
-
+ Math.random()} />
); } diff --git a/modern/src/reports/TripReportPage.js b/modern/src/reports/TripReportPage.js index 82c5439b..45a7786c 100644 --- a/modern/src/reports/TripReportPage.js +++ b/modern/src/reports/TripReportPage.js @@ -59,7 +59,7 @@ const TripReportPage = () => { flex: 1, valueFormatter: ({ value }) => formatDate(value), }, { - headerName: t('reportStartOdometer'), + headerName: t('reportEndOdometer'), field: 'endOdometer', type: 'number', flex: 1, -- cgit v1.2.3