diff options
Diffstat (limited to 'modern/src/reports/TripReportPage.js')
-rw-r--r-- | modern/src/reports/TripReportPage.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/modern/src/reports/TripReportPage.js b/modern/src/reports/TripReportPage.js index ffe16241..a1420591 100644 --- a/modern/src/reports/TripReportPage.js +++ b/modern/src/reports/TripReportPage.js @@ -1,4 +1,5 @@ import React, { useState } from 'react'; +import { useNavigate } from 'react-router-dom'; import { IconButton, Table, TableBody, TableCell, TableHead, TableRow, } from '@mui/material'; @@ -23,6 +24,7 @@ import TableShimmer from '../common/components/TableShimmer'; import MapMarkers from '../map/MapMarkers'; import MapCamera from '../map/MapCamera'; import MapGeofence from '../map/MapGeofence'; +import scheduleReport from './common/scheduleReport'; const columnsArray = [ ['startTime', 'reportStartTime'], @@ -41,6 +43,7 @@ const columnsArray = [ const columnsMap = new Map(columnsArray); const TripReportPage = () => { + const navigate = useNavigate(); const classes = useReportStyles(); const t = useTranslation(); @@ -116,6 +119,16 @@ const TripReportPage = () => { } }); + const handleSchedule = useCatch(async (deviceIds, groupIds, report) => { + report.type = 'trips'; + const error = await scheduleReport(deviceIds, groupIds, report); + if (error) { + throw Error(error); + } else { + navigate('/reports/scheduled'); + } + }); + const formatValue = (item, key) => { switch (key) { case 'startTime': @@ -160,7 +173,7 @@ const TripReportPage = () => { )} <div className={classes.containerMain}> <div className={classes.header}> - <ReportFilter handleSubmit={handleSubmit}> + <ReportFilter handleSubmit={handleSubmit} handleSchedule={handleSchedule}> <ColumnSelect columns={columns} setColumns={setColumns} columnsArray={columnsArray} /> </ReportFilter> </div> |