feat: add recharts analytics to admin campaign stats page

- Move shared chart components (DailyChart, PeriodComparison, StatCard) to src/components/stats/ with configurable label props
- Create shared types for chart data decoupled from partner API
- Add campaign chart data API client with deposits/spending split
- Enhance AdminCampaignStats with daily trends chart, period comparison, top registrations, and deposit/spending stat cards
- Add useChartColors hook with SSR guard and theme-aware CSS variable parsing
- Add cross-platform clipboard utility with execCommand fallback for Telegram WebView
- Add i18n keys for chart analytics across all 4 locales (en, ru, zh, fa)
- Responsive fixes: truncation for long names/values, responsive text sizing, touch-friendly copy buttons
This commit is contained in:
Fringg
2026-03-02 06:10:20 +03:00
parent 60f16e64e8
commit c7d05c4809
21 changed files with 1577 additions and 158 deletions

39
src/constants/partner.ts Normal file
View File

@@ -0,0 +1,39 @@
export const PARTNER_STATS = {
/** Chart visual configuration */
CHART: {
HEIGHT: 200,
MARGIN: { top: 5, right: 10, left: 0, bottom: 5 },
},
/** Kopeks-to-currency divisor */
KOPEKS_DIVISOR: 100,
/** Copy feedback duration in ms */
COPY_FEEDBACK_MS: 2000,
/** Gradient stop offsets */
GRADIENT: {
START_OFFSET: '5%',
END_OFFSET: '95%',
START_OPACITY: 0.3,
END_OPACITY: 0,
},
/** Axis tick styling */
AXIS: {
TICK_FONT_SIZE: 11,
EARNINGS_WIDTH: 45,
REFERRALS_WIDTH: 30,
},
/** Tooltip styling */
TOOLTIP: {
BORDER_RADIUS: '8px',
FONT_SIZE: '12px',
},
/** Area stroke width */
STROKE_WIDTH: 2,
/** Grid dash array */
GRID_DASH: '3 3',
/** Skeleton count for loading state */
SKELETON_COUNT: 3,
/** Maximum conversion rate for progress bar */
MAX_CONVERSION_RATE: 100,
/** Stale time for campaign stats query (ms) */
STATS_STALE_TIME: 60_000,
} as const;