import React, { useState } from 'react'; // material-ui import { Box, Button, Grid, Menu, MenuItem, Typography } from '@mui/material'; // third party import Chart, { Props as ChartProps } from 'react-apexcharts'; // project imports import MainCard from './MainCard'; import { GenericCardProps } from 'types'; // assets import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward'; import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward'; // ==========================|| ANALYTICS CHART CARD ||========================== // export interface AnalyticsChartCardProps extends GenericCardProps { title: string; chartData: ChartProps; dropData: { options: { label: string; value: number }[]; title: string }; listData: { color: string; value: number; icon: React.ReactNode | string; state: number; percentage: number }[]; } const AnalyticsChartCard = ({ title, chartData, dropData, listData }: AnalyticsChartCardProps) => { const [anchorEl, setAnchorEl] = useState Element) | null | undefined>(null); let dropHtml; if (dropData) { const handleClick = (event: React.MouseEvent | undefined) => { setAnchorEl(event?.currentTarget); }; const handleClose = () => { setAnchorEl(null); }; dropHtml = ( <> {dropData?.options.map((option, index) => ( {option.label} ))} ); } let listItem; if (listData) { listItem = listData.map((item, index) => ( {item.icon} {item.value}% {item.state === 1 && } {item.state === 0 && } {item.percentage}% )); } return ( {title && ( {title} )} {dropHtml} {listItem} ); }; export default AnalyticsChartCard;