"use client" import { useState, useEffect } from "react" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Sparkles, Music, Trophy, Star, Calendar, Target, Eye } from "lucide-react" import { getApiUrl } from "@/lib/api-config" import { motion } from "framer-motion" interface ProfileStats { shows_attended: number unique_songs_seen: number debuts_witnessed: number heady_versions_attended: number top_10_performances: number total_ratings: number total_reviews: number chase_songs_count: number chase_songs_caught: number most_seen_song: string | null most_seen_count: number } export function AttendanceSummary() { const [stats, setStats] = useState(null) const [loading, setLoading] = useState(true) useEffect(() => { fetchStats() }, []) const fetchStats = async () => { const token = localStorage.getItem("token") if (!token) { setLoading(false) return } try { const res = await fetch(`${getApiUrl()}/chase/profile/stats`, { headers: { Authorization: `Bearer ${token}` } }) if (res.ok) { const data = await res.json() setStats(data) } } catch (err) { console.error("Failed to fetch profile stats", err) } finally { setLoading(false) } } if (loading) { return
Loading stats...
} if (!stats || stats.shows_attended === 0) { return ( Attendance Summary

No shows marked as attended yet. Start adding shows to see your stats!

) } // Build the summary sentence const highlights: string[] = [] if (stats.heady_versions_attended > 0) { highlights.push(`${stats.heady_versions_attended} heady version${stats.heady_versions_attended !== 1 ? 's' : ''}`) } if (stats.top_10_performances > 0) { highlights.push(`${stats.top_10_performances} top-rated performance${stats.top_10_performances !== 1 ? 's' : ''}`) } if (stats.debuts_witnessed > 0) { highlights.push(`${stats.debuts_witnessed} debut${stats.debuts_witnessed !== 1 ? 's' : ''}`) } return ( Your Attendance Story {/* Main Summary */}

You've attended {stats.shows_attended} shows and seen {stats.unique_songs_seen} unique songs.

{highlights.length > 0 && (

In attendance for {highlights.join(", ")}.

)} {stats.most_seen_song && (

Your most-seen song is {stats.most_seen_song} ({stats.most_seen_count} times).

)}
{/* Stats Grid */}
{stats.shows_attended}
Shows
{stats.unique_songs_seen}
Songs Seen
{stats.heady_versions_attended}
Heady Versions
{stats.debuts_witnessed}
Debuts
{/* Chase Songs Progress */} {stats.chase_songs_count > 0 && (
Chase Progress
{stats.chase_songs_caught}/{stats.chase_songs_count}

{stats.chase_songs_count - stats.chase_songs_caught} songs left to catch!

)} {/* Activity Stats */}
{stats.total_ratings} ratings
{stats.total_reviews} reviews
) }