"use client"
import Link from "next/link"
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
import { Calendar, MapPin, Youtube, Music2 } from "lucide-react"
import { Button } from "@/components/ui/button"
interface Show {
id: number
slug?: string
date: string
youtube_link?: string
vertical?: {
name: string
slug: string
}
venue: {
id: number
name: string
city: string
state: string
}
}
interface DateGroupedListProps {
shows: Show[]
}
export function DateGroupedList({ shows }: DateGroupedListProps) {
if (shows.length === 0) {
return (
No shows found matching your filters.
)
}
// Group shows by date
const groupedShows: Record = {}
shows.forEach(show => {
// Use local date string to avoid timezone shifts if possible, or usually just split T
const dateKey = new Date(show.date).toLocaleDateString(undefined, {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric'
})
if (!groupedShows[dateKey]) {
groupedShows[dateKey] = []
}
groupedShows[dateKey].push(show)
})
// Sort dates (descending) - assuming API returned sorted, but safe to re-sort keys if list order isn't guaranteed
// Actually relying on input order is safer if we trust the API to sort by date desc.
// Let's just iterate over the unique keys in the order they appear (which will be desc if input is desc)
const uniqueDates = Array.from(new Set(shows.map(s =>
new Date(s.date).toLocaleDateString(undefined, {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric'
})
)))
return (