import { notFound } from "next/navigation" import { VERTICALS } from "@/config/verticals" import { getApiUrl } from "@/lib/api-config" import Link from "next/link" import { Calendar, MapPin, Music, Trophy, Video, Ticket, Building, ChevronRight } from "lucide-react" import { Card, CardContent } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { Badge } from "@/components/ui/badge" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table" import { Show, Song, PaginatedResponse } from "@/types/models" interface Props { params: Promise<{ vertical: string }> } export function generateStaticParams() { return VERTICALS.map((v) => ({ vertical: v.slug, })) } async function getRecentShows(verticalSlug: string): Promise { try { // Fetch 10 recent shows const res = await fetch(`${getApiUrl()}/shows/?vertical_slugs=${verticalSlug}&limit=10&status=past`, { next: { revalidate: 60 } }) if (!res.ok) return [] const data: PaginatedResponse = await res.json() return data.data || [] } catch { return [] } } async function getTopSongs(verticalSlug: string): Promise { try { // Fetch top 10 songs, assuming backend now populates times_played const res = await fetch(`${getApiUrl()}/songs/?vertical=${verticalSlug}&limit=10&sort=times_played`, { next: { revalidate: 60 } }) if (!res.ok) return [] const data: PaginatedResponse = await res.json() return data.data || [] } catch { return [] } } async function getVerticalStats(verticalSlug: string) { try { const res = await fetch(`${getApiUrl()}/bands/${verticalSlug}`, { next: { revalidate: 300 } }) if (!res.ok) return null return res.json() } catch { return null } } export default async function VerticalPage({ params }: Props) { const { vertical: verticalSlug } = await params const vertical = VERTICALS.find((v) => v.slug === verticalSlug) if (!vertical) { notFound() } const [recentShows, topSongs, bandProfile] = await Promise.all([ getRecentShows(verticalSlug), getTopSongs(verticalSlug), getVerticalStats(verticalSlug) ]) const stats = bandProfile?.stats || {} return (
{/* Hero Section - Compact & Utilitarian */}

{vertical.name}

{vertical.description}

{/* High-Level Stats */}
{stats.total_shows || 0}
Shows
{stats.total_songs || 0}
Songs
{stats.total_venues || 0}
Venues
{/* Quick Actions Bar */}
{/* Recent Shows Table */}

Recent Shows

Date Venue Location {recentShows.length === 0 ? ( No shows found ) : ( recentShows.map((show) => ( {new Date(show.date).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })} {show.venue?.name || "Unknown"} {show.venue?.city}, {show.venue?.state} )) )}
{/* Most Played Songs Table */}

Most Played Songs

Title Plays {topSongs.length === 0 ? ( No songs found ) : ( topSongs.map((song) => ( {song.title} {song.original_artist && ( by {song.original_artist} )} {song.times_played || 0} )) )}
) }