import React, { useState } from 'react'; import { FormControl, InputLabel, Select, MenuItem } from '@material-ui/core'; import ReportLayoutPage from './ReportLayoutPage'; import ReportFilter from './ReportFilter'; import Graph from './Graph'; import { useAttributePreference } from '../common/preferences'; import { formatDate } from '../common/formatter'; import { speedConverter } from '../common/converter'; import t from '../common/localization'; const Filter = ({ children, setItems }) => { const speedUnit = useAttributePreference('speedUnit'); const handleSubmit = 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 positions = await response.json(); let formattedPositions = positions.map(position => { return { speed: Number(speedConverter(position.speed, speedUnit)), altitude: position.altitude, accuracy: position.accuracy, fixTime: formatDate(position.fixTime) } }); setItems(formattedPositions); } } return ( <> {children} ) } const ChartType = ({ type, setType }) => { return ( {t('reportChartType')} ) } const ChartReportPage = () => { const [items, setItems] = useState([]); const [type, setType] = useState('speed'); return ( <> }> ) } export default ChartReportPage;