"use client" import { useEffect, useState } from "react" import { getApiUrl } from "@/lib/api-config" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" import { Skeleton } from "@/components/ui/skeleton" import { Youtube, Calendar, MapPin, Music, Film } from "lucide-react" import Link from "next/link" interface PerformanceVideo { type: "performance" id: number youtube_link: string show_id: number song_id: number song_title: string song_slug: string date: string show_slug: string venue_name: string venue_city: string venue_state: string | null } interface ShowVideo { type: "full_show" id: number youtube_link: string date: string show_slug: string venue_name: string venue_city: string venue_state: string | null } interface VideoStats { performance_videos: number full_show_videos: number total: number } export default function VideosPage() { const [performances, setPerformances] = useState([]) const [shows, setShows] = useState([]) const [stats, setStats] = useState(null) const [loading, setLoading] = useState(true) const [activeTab, setActiveTab] = useState<"all" | "songs" | "shows">("all") useEffect(() => { Promise.all([ fetch(`${getApiUrl()}/videos/?limit=500`).then(r => r.json()), fetch(`${getApiUrl()}/videos/stats`).then(r => r.json()) ]) .then(([videoData, statsData]) => { setPerformances(videoData.performances) setShows(videoData.shows) setStats(statsData) }) .catch(console.error) .finally(() => setLoading(false)) }, []) const extractVideoId = (url: string) => { const match = url.match(/[?&]v=([^&]+)/) return match ? match[1] : null } if (loading) { return (
{Array.from({ length: 10 }).map((_, i) => ( ))}
) } const filteredPerformances = activeTab === "shows" ? [] : performances const filteredShows = activeTab === "songs" ? [] : shows // Combine and sort by date const allVideos = [ ...filteredPerformances.map(p => ({ ...p, sortDate: p.date })), ...filteredShows.map(s => ({ ...s, sortDate: s.date, song_title: "Full Show" })) ].sort((a, b) => new Date(b.sortDate).getTime() - new Date(a.sortDate).getTime()) return (

Videos

{stats && (

{stats.total} videos available • {stats.full_show_videos} full shows • {stats.performance_videos} song performances

)}
{/* Filter Tabs */}
{/* Video List */}
{allVideos.map((video, idx) => (
{/* YouTube Icon/Link */} {/* Content */}
{video.type === "full_show" ? ( Full Show ) : ( {(video as PerformanceVideo).song_title} )} {video.type === "full_show" ? "Full Show" : "Song"}
{new Date(video.date).toLocaleDateString(undefined, { year: "numeric", month: "short", day: "numeric" })} {video.venue_name}, {video.venue_city} {video.venue_state && `, ${video.venue_state}`}
{/* Show Link */} View Show →
))}
) }