diff options
Diffstat (limited to 'modern/src/reports/StatisticsPage.js')
-rw-r--r-- | modern/src/reports/StatisticsPage.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/modern/src/reports/StatisticsPage.js b/modern/src/reports/StatisticsPage.js index 214773fe..b1652468 100644 --- a/modern/src/reports/StatisticsPage.js +++ b/modern/src/reports/StatisticsPage.js @@ -9,6 +9,7 @@ import ReportsMenu from './components/ReportsMenu'; import ReportFilter from './components/ReportFilter'; import usePersistedState from '../common/util/usePersistedState'; import ColumnSelect from './components/ColumnSelect'; +import { useCatch } from '../reactHelper'; const columnsArray = [ ['captureTime', 'statisticsCaptureTime'], @@ -30,13 +31,15 @@ const StatisticsPage = () => { const [columns, setColumns] = usePersistedState('statisticsColumns', ['captureTime', 'activeUsers', 'activeDevices', 'messagesStored']); const [items, setItems] = useState([]); - const handleSubmit = async (_, from, to) => { + const handleSubmit = useCatch(async (_, from, to) => { const query = new URLSearchParams({ from, to }); const response = await fetch(`/api/statistics?${query.toString()}`, { Accept: 'application/json' }); if (response.ok) { setItems(await response.json()); + } else { + throw Error(await response.text()); } - }; + }); return ( <PageLayout menu={<ReportsMenu />} breadcrumbs={['reportTitle', 'statisticsTitle']}> |