import React, { useState } from 'react'; import { IconButton, Table, TableBody, TableCell, TableHead, TableRow, } from '@mui/material'; import GpsFixedIcon from '@mui/icons-material/GpsFixed'; import LocationSearchingIcon from '@mui/icons-material/LocationSearching'; import ReportFilter from './components/ReportFilter'; import { useTranslation } from '../common/components/LocalizationProvider'; import PageLayout from '../common/components/PageLayout'; import ReportsMenu from './components/ReportsMenu'; import usePersistedState from '../common/util/usePersistedState'; import PositionValue from '../common/components/PositionValue'; import ColumnSelect from './components/ColumnSelect'; import usePositionAttributes from '../common/attributes/usePositionAttributes'; import { useCatch } from '../reactHelper'; import MapView from '../map/core/MapView'; import MapRoutePath from '../map/MapRoutePath'; import MapPositions from '../map/MapPositions'; import useReportStyles from './common/useReportStyles'; const RouteReportPage = () => { const classes = useReportStyles(); const t = useTranslation(); const positionAttributes = usePositionAttributes(t); const [columns, setColumns] = usePersistedState('routeColumns', ['fixTime', 'latitude', 'longitude', 'speed', 'address']); const [items, setItems] = useState([]); const [selectedItem, setSelectedItem] = useState(null); const handleSubmit = useCatch(async ({ deviceId, from, to, mail, headers }) => { const query = new URLSearchParams({ deviceId, from, to, mail }); const response = await fetch(`/api/reports/route?${query.toString()}`, { headers }); if (response.ok) { const contentType = response.headers.get('content-type'); if (contentType) { if (contentType === 'application/json') { setItems(await response.json()); } else { window.location.assign(window.URL.createObjectURL(await response.blob())); } } } else { throw Error(await response.text()); } }); return ( } breadcrumbs={['reportTitle', 'reportRoute']}>
{selectedItem && (
)}
{columns.map((key) => ({positionAttributes[key].name}))} {items.map((item) => ( {selectedItem === item ? ( setSelectedItem(null)}> ) : ( setSelectedItem(item)}> )} {columns.map((key) => ( ))} ))}
); }; export default RouteReportPage;