'use client'; import {useId} from 'react'; import {Area, AreaChart, CartesianGrid, Tooltip, XAxis, YAxis} from 'recharts'; import {Card} from '@astryxdesign/core/Card'; import {VStack} from '@astryxdesign/core/Layout'; import {Text} from '@astryxdesign/core/Text'; import {ChartFrame, AXIS_TICK} from '@/shared/components/charts/ChartFrame'; import {CHART} from '@/shared/components/charts/palette'; import {useChartMotion} from '@/shared/components/charts/useChartMotion'; import {formatCount, formatInr, formatInrCompact} from '@/shared/utils/format'; import type {TrendPoint} from '@/features/commerce/services/salesAnalysis'; /** * Daily sales across the selected period — compact, one area in brand warm * (sales are money, and money is warm on this console). * * Its own small chart rather than AreaChartView because the tooltip needs two * units at once — rupees for sales, a plain count for purchases — and the * shared tooltip formats every series with the one `yFormat`. */ export function SalesTrendChart({ data, height = 180, }: { data: TrendPoint[]; height?: number; }) { const uid = useId().replace(/:/g, ''); const motion = useChartMotion(true); return ( formatInrCompact(v)} /> { const p = active ? (payload?.[0]?.payload as TrendPoint | undefined) : undefined; if (!p) return null; return ( {p.label} Sales {formatInr(p.sales)} Purchases {formatCount(p.purchases)} ); }} /> ); }