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