import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { Bar, BarChart, CartesianGrid, Cell, ResponsiveContainer, Tooltip, XAxis, YAxis, } from 'recharts'; import { SALES_STATS } from '../../constants/salesStats'; import { useChartColors } from '../../hooks/useChartColors'; interface SimpleBarChartProps { data: { name: string; value: number; color?: string }[]; title: string; height?: number; valueFormatter?: (value: number) => string; } const BAR_CHART_MARGIN = { ...SALES_STATS.CHART.MARGIN, bottom: 40, }; export function SimpleBarChart({ data, title, height = SALES_STATS.CHART.HEIGHT, valueFormatter, }: SimpleBarChartProps) { const { t } = useTranslation(); const colors = useChartColors(); const adjustedHeight = useMemo(() => height + 35, [height]); if (data.length === 0) { return (

{title}

{t('common.noData')}
); } return (

{title}

[ valueFormatter ? valueFormatter(value ?? 0) : (value ?? 0), ]} /> {data.map((entry, index) => ( ))}
); }