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) => ({ value, id: !id || id.length > 100 ? "Не определено" : id, color: COLORS[index], })); return ( {title} {data.map(({ id, value, color }, index) => ( {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)); return ( Статистика пользователей ); };