aboutsummaryrefslogtreecommitdiff
path: root/modern/src/reports/SummaryReportPage.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/reports/SummaryReportPage.js')
-rw-r--r--modern/src/reports/SummaryReportPage.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/modern/src/reports/SummaryReportPage.js b/modern/src/reports/SummaryReportPage.js
index d66d58c6..ec5395f1 100644
--- a/modern/src/reports/SummaryReportPage.js
+++ b/modern/src/reports/SummaryReportPage.js
@@ -1,5 +1,6 @@
import React, { useState } from 'react';
import { useSelector } from 'react-redux';
+import { useNavigate } from 'react-router-dom';
import {
FormControl, InputLabel, Select, MenuItem, Table, TableHead, TableRow, TableBody, TableCell,
} from '@mui/material';
@@ -16,6 +17,7 @@ import ColumnSelect from './components/ColumnSelect';
import { useCatch } from '../reactHelper';
import useReportStyles from './common/useReportStyles';
import TableShimmer from '../common/components/TableShimmer';
+import scheduleReport from './common/scheduleReport';
const columnsArray = [
['startTime', 'reportStartDate'],
@@ -30,6 +32,7 @@ const columnsArray = [
const columnsMap = new Map(columnsArray);
const SummaryReportPage = () => {
+ const navigate = useNavigate();
const classes = useReportStyles();
const t = useTranslation();
@@ -73,6 +76,17 @@ const SummaryReportPage = () => {
}
});
+ const handleSchedule = useCatch(async (deviceIds, groupIds, report) => {
+ report.type = 'summary';
+ report.attributes.daily = daily;
+ const error = await scheduleReport(deviceIds, groupIds, report);
+ if (error) {
+ throw Error(error);
+ } else {
+ navigate('/reports/scheduled');
+ }
+ });
+
const formatValue = (item, key) => {
switch (key) {
case 'deviceId':
@@ -98,7 +112,7 @@ const SummaryReportPage = () => {
return (
<PageLayout menu={<ReportsMenu />} breadcrumbs={['reportTitle', 'reportSummary']}>
<div className={classes.header}>
- <ReportFilter handleSubmit={handleSubmit} multiDevice includeGroups>
+ <ReportFilter handleSubmit={handleSubmit} handleSchedule={handleSchedule} multiDevice includeGroups>
<div className={classes.filterItem}>
<FormControl fullWidth>
<InputLabel>{t('sharedType')}</InputLabel>