import { FC } from "react"; import { Box, Paper, Typography, useMediaQuery, useTheme } from "@mui/material"; import { PieChart } from "@mui/x-charts"; import type { DevicesResponse } from "@api/statistic"; type DeviceProps = { title: string; devices: Record | null; }; type DevicesProps = { data: DevicesResponse | null; }; const COLORS: Record = { 0: "#7E2AEA", 1: "#FA7738", 2: "#62BB1C", 3: "#0886FB", }; const Device = ({ title, devices }: DeviceProps) => { const theme = useTheme(); if (!devices || !Object.keys(devices ?? {}).length) { return {title} - нет данных; } const data = Object.entries(devices).map(([id, value], index) => ({ id, value, color: COLORS[index], })); return ( {title} {data.map(({ id, value, color }) => ( {id ? id : "Неопределено"} {value.toFixed(1)} % ))} ); }; export const Devices: FC = ({ data }) => { const theme = useTheme(); const isTablet = useMediaQuery(theme.breakpoints.down(1000)); const isMobile = useMediaQuery(theme.breakpoints.down(700)); // useEffect(() => { // const requestDevices = async () => { // const [devicesResponse, devicesError] = await getDevices("14761"); // if (devicesError) { // enqueueSnackbar(devicesError); // return; // } // if (!devicesResponse) { // enqueueSnackbar("Список девайсов пуст."); // return; // } // setDevices(devicesResponse); // }; // // requestDevices(); // }, []); return ( Статистика пользователей ); };