"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 { Show } from "@/types/models" 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 (
{uniqueDates.map(dateStr => (

{dateStr}

{groupedShows[dateStr].map(show => ( {/* Vertical Stripe/Badge */} {show.vertical && (
)} {show.youtube_link && (
)} {/* Added padding-left for stripe */} {show.vertical && ( {show.vertical.name} )} {show.venue?.name}
{show.venue?.city}, {show.venue?.state}
))}
))}
) }