import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { Area, AreaChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis, } from 'recharts'; import type { DailyStatItem } from './types'; import { PARTNER_STATS } from '../../constants/partner'; import { useCurrency } from '../../hooks/useCurrency'; import { useChartColors } from '../../hooks/useChartColors'; interface DailyChartProps { data: DailyStatItem[]; chartId: string | number; title?: string; earningsLabel?: string; countLabel?: string; } interface ChartDataItem extends DailyStatItem { earnings_display: number; label: string; } export function DailyChart({ data, chartId, title, earningsLabel, countLabel }: DailyChartProps) { const { t, i18n } = useTranslation(); const { formatWithCurrency } = useCurrency(); const colors = useChartColors(); const resolvedTitle = title ?? t('referral.partner.stats.dailyChart'); const resolvedEarningsLabel = earningsLabel ?? t('referral.partner.stats.earnings'); const resolvedCountLabel = countLabel ?? t('referral.partner.stats.referrals'); const chartData: ChartDataItem[] = useMemo( () => data.map((item) => ({ ...item, earnings_display: item.earnings_kopeks / PARTNER_STATS.KOPEKS_DIVISOR, label: new Date(item.date + 'T00:00:00').toLocaleDateString(i18n.language, { month: 'short', day: 'numeric', }), })), [data, i18n.language], ); return (