aboutsummaryrefslogtreecommitdiff
path: root/modern/src/reports/StopReportPage.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/reports/StopReportPage.js')
-rw-r--r--modern/src/reports/StopReportPage.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/modern/src/reports/StopReportPage.js b/modern/src/reports/StopReportPage.js
index ce790401..3a6ee18d 100644
--- a/modern/src/reports/StopReportPage.js
+++ b/modern/src/reports/StopReportPage.js
@@ -1,4 +1,5 @@
import React, { useState } from 'react';
+import { useNavigate } from 'react-router-dom';
import {
IconButton,
Table, TableBody, TableCell, TableHead, TableRow,
@@ -23,6 +24,7 @@ import MapCamera from '../map/MapCamera';
import AddressValue from '../common/components/AddressValue';
import TableShimmer from '../common/components/TableShimmer';
import MapGeofence from '../map/MapGeofence';
+import scheduleReport from './common/scheduleReport';
const columnsArray = [
['startTime', 'reportStartTime'],
@@ -36,6 +38,7 @@ const columnsArray = [
const columnsMap = new Map(columnsArray);
const StopReportPage = () => {
+ const navigate = useNavigate();
const classes = useReportStyles();
const t = useTranslation();
@@ -74,6 +77,16 @@ const StopReportPage = () => {
}
});
+ const handleSchedule = useCatch(async (deviceIds, groupIds, report) => {
+ report.type = 'stops';
+ const error = await scheduleReport(deviceIds, groupIds, report);
+ if (error) {
+ throw Error(error);
+ } else {
+ navigate('/reports/scheduled');
+ }
+ });
+
const formatValue = (item, key) => {
switch (key) {
case 'startTime':
@@ -116,7 +129,7 @@ const StopReportPage = () => {
)}
<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>