import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { Area, AreaChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis, } from 'recharts'; import { SALES_STATS } from '../../constants/salesStats'; import { useChartColors } from '../../hooks/useChartColors'; interface SimpleAreaChartProps { data: { date: string; value: number }[]; title: string; color?: string; chartId: string; valueLabel?: string; height?: number; } export function SimpleAreaChart({ data, title, color, chartId, valueLabel, height = SALES_STATS.CHART.HEIGHT, }: SimpleAreaChartProps) { const { t, i18n } = useTranslation(); const colors = useChartColors(); const strokeColor = color || colors.earnings; const chartData = useMemo( () => data.map((item) => ({ ...item, label: new Date(item.date + 'T00:00:00').toLocaleDateString(i18n.language, { month: 'short', day: 'numeric', }), })), [data, i18n.language], ); if (data.length === 0) { return (

{title}

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

{title}

[value ?? 0, valueLabel || '']} />
); }