import * as React from "react"; import { Box, Typography, ToggleButtonGroup, ToggleButton, Paper } from "@mui/material"; export interface ChartDataPoint { id: string; amount: number; count?: number; highlighted?: boolean; } export interface HistoryChartProps { header: string; summary?: string; tabs: string[]; data: Record; } export default function HistoryChart({ header, summary, tabs, data, }: HistoryChartProps) { const [activeTab, setActiveTab] = React.useState(tabs[0] || ""); const handleTabChange = (_: React.MouseEvent, newTab: string | null) => { if (newTab !== null) { setActiveTab(newTab); } }; const activeDataKey = activeTab.toLowerCase(); const currentData = data[activeDataKey] || data[activeTab] || []; const maxAmount = Math.max(...currentData.map((d) => d.amount), 1); return ( {header} {summary && ( {summary} )} theme.palette.mode === 'dark' ? 'rgba(255,255,255,0.05)' : 'rgba(0,0,0,0.02)', borderRadius: 8, p: 0.5, "& .MuiToggleButton-root": { border: "none", borderRadius: 8, textTransform: "capitalize", fontWeight: 600, color: "text.secondary", "&.Mui-selected": { bgcolor: (theme) => theme.palette.mode === 'dark' ? 'primary.dark' : 'primary.light', color: (theme) => theme.palette.mode === 'dark' ? 'primary.contrastText' : 'primary.main', boxShadow: '0 2px 8px rgba(0,0,0,0.05)', }, }, }} > {tabs.map((tab) => ( {tab} ))} {/* Chart Area */} {currentData.length > 0 ? ( {currentData.map((point) => { const heightPerc = (point.amount / maxAmount) * 100; return ( {point.amount > 0 ? `Rs ${point.amount}` : ''} `0 4px 12px ${theme.palette.error.main}40`, }), }} /> {point.id} ); })} ) : ( No Data Available )} ); }