import React, { useState, useEffect } from 'react'; import { AuthProvider, AuthGuard, useAuth } from './AdminAuth'; import AdminLayout from './AdminLayout'; import { LineChart, Line, XAxis, YAxis, Tooltip, ResponsiveContainer, BarChart, Bar, PieChart, Pie, Cell } from 'recharts'; const COLORS = ['#00FF6A', '#00CC55', '#FF6B35', '#FFD700', '#FF3B3B', '#6366F1', '#06B6D4']; function StatCard({ label, value }: { label: string; value: string }) { return (
{value}
{label}
); } function AnalyticsContent() { const { token } = useAuth(); const [days, setDays] = useState(30); const [tab, setTab] = useState<'clicks' | 'revenue' | 'conversions'>('clicks'); // Mock data const timeseries = Array.from({ length: days }, (_, i) => ({ date: new Date(Date.now() - (days - 1 - i) * 86400000).toISOString().slice(0, 10), clicks: Math.floor(Math.random() * 300 + 100), revenue: Math.floor(Math.random() * 150 + 20), conversions: Math.floor(Math.random() * 15 + 1), })); const totalClicks = timeseries.reduce((s, d) => s + d.clicks, 0); const totalRevenue = timeseries.reduce((s, d) => s + d.revenue, 0); const totalConversions = timeseries.reduce((s, d) => s + d.conversions, 0); const ctr = totalClicks > 0 ? (totalConversions / totalClicks * 100).toFixed(2) : '0'; const roas = (totalRevenue / Math.max(totalClicks * 0.15, 1)).toFixed(2); const topProducts = [ { name: 'Nike Dunk Low Panda', clicks: 342, revenue: 89 }, { name: 'NB 550 White Grey', clicks: 234, revenue: 67 }, { name: 'Adidas Samba OG', clicks: 198, revenue: 54 }, { name: 'Nike Air Max 90', clicks: 167, revenue: 43 }, { name: 'Asics Gel-1130', clicks: 134, revenue: 38 }, ]; const topShops = [ { name: 'Footlocker', revenue: 124 }, { name: 'JD Sports', revenue: 98 }, { name: 'Zalando', revenue: 76 }, { name: 'Sneakerstad', revenue: 54 }, ]; const sources = [ { name: 'Homepage', value: 42 }, { name: 'Search', value: 31 }, { name: 'Deals', value: 18 }, { name: 'Google', value: 9 }, ]; return (
{[7, 14, 30, 90].map(d => ( ))}
{(['clicks', 'revenue', 'conversions'] as const).map(t => ( ))}
v.slice(5)} />

Top Products

{topProducts.map((p, i) => (
{i + 1}. {p.name}
{p.clicks} clicks €{p.revenue}
))}

Top Shops by Revenue

{topShops.map((s, i) => (
{i + 1}. {s.name}
€{s.revenue}
))}

Traffic Sources

{sources.map((_, i) => )}
{sources.map((s, i) => (
{s.name} {s.value}%
))}

Revenue by Network

Webgains
€210 (61%)
TradeTracker
€132 (39%)
); } export default function AnalyticsPage() { return ; }