'use client'; import { useState, useEffect } from 'react'; import Card from '@/components/ui/Card'; import Button from '@/components/ui/Button'; import { BarChart3, Eye, Users, Trophy, TrendingUp, Calendar, DollarSign, Target, ArrowUpRight, ArrowDownRight, ExternalLink, Loader2 } from 'lucide-react'; import Link from 'next/link'; interface SponsorshipMetrics { impressions: number; impressionsChange: number; uniqueViewers: number; viewersChange: number; races: number; drivers: number; exposure: number; exposureChange: number; } interface SponsoredLeague { id: string; name: string; tier: 'main' | 'secondary'; drivers: number; races: number; impressions: number; status: 'active' | 'upcoming' | 'completed'; } interface SponsorDashboardData { sponsorId: string; sponsorName: string; metrics: SponsorshipMetrics; sponsoredLeagues: SponsoredLeague[]; investment: { activeSponsorships: number; totalInvestment: number; costPerThousandViews: number; }; } function MetricCard({ title, value, change, icon: Icon, suffix = '', }: { title: string; value: number | string; change?: number; icon: typeof Eye; suffix?: string; }) { const isPositive = change && change > 0; const isNegative = change && change < 0; return (
{change !== undefined && (
{isPositive ? : isNegative ? : null} {Math.abs(change)}%
)}
{typeof value === 'number' ? value.toLocaleString() : value}{suffix}
{title}
); } function LeagueRow({ league }: { league: SponsoredLeague }) { const statusColors = { active: 'bg-performance-green/20 text-performance-green', upcoming: 'bg-warning-amber/20 text-warning-amber', completed: 'bg-gray-500/20 text-gray-400', }; const tierColors = { main: 'bg-primary-blue/20 text-primary-blue border-primary-blue/30', secondary: 'bg-purple-500/20 text-purple-400 border-purple-500/30', }; return (
{league.tier === 'main' ? 'Main Sponsor' : 'Secondary'}
{league.name}
{league.drivers} drivers • {league.races} races
{league.impressions.toLocaleString()}
impressions
{league.status}
); } export default function SponsorDashboardPage() { const [timeRange, setTimeRange] = useState<'7d' | '30d' | '90d' | 'all'>('30d'); const [data, setData] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { async function fetchDashboard() { try { const response = await fetch('/api/sponsors/dashboard'); if (response.ok) { const dashboardData: SponsorDashboardData = await response.json(); setData(dashboardData); } else { setError('Failed to load sponsor dashboard'); } } catch { setError('Failed to load sponsor dashboard'); } finally { setLoading(false); } } fetchDashboard(); }, []); if (loading) { return (
); } if (!data) { return (

{error ?? 'No sponsor dashboard data available yet.'}

); } const dashboardData = data; return (
{/* Header */}

Sponsor Dashboard

Track your sponsorship performance and exposure

{(['7d', '30d', '90d', 'all'] as const).map((range) => ( ))}
{/* Metrics Grid */}
{/* Sponsored Leagues */}

Sponsored Leagues

{dashboardData.sponsoredLeagues.length > 0 ? ( dashboardData.sponsoredLeagues.map((league) => ( )) ) : (

No active sponsorships yet.

Browse leagues to sponsor
)}
{/* Quick Stats & Actions */}
{/* Investment Summary */}

Investment Summary

Active Sponsorships {dashboardData.investment.activeSponsorships}
Total Investment ${dashboardData.investment.totalInvestment.toLocaleString()}
Cost per 1K Views ${dashboardData.investment.costPerThousandViews.toFixed(2)}
Next Payment Dec 15, 2025
{/* Recent Activity */}

Recent Activity

GT3 Pro Championship race completed

2 hours ago • 1,240 views

New driver joined Endurance Masters

5 hours ago

Touring Car Cup season starting soon

1 day ago

{/* Quick Actions */}

Quick Actions

{/* Alpha Notice */}

Alpha Note: Sponsor analytics data shown here is demonstration-only. Real analytics will be available when the sponsorship system is fully implemented.

); }