"use client" import { useEffect, useState } from "react" import { getApiUrl } from "@/lib/api-config" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import Link from "next/link" import { Map } from "lucide-react" interface Tour { id: number name: string start_date: string end_date: string } export default function ToursPage() { const [tours, setTours] = useState([]) const [loading, setLoading] = useState(true) useEffect(() => { fetch(`${getApiUrl()}/tours/?limit=100`) .then(res => res.json()) .then(data => { // Sort by start date descending const sorted = data.sort((a: Tour, b: Tour) => new Date(b.start_date).getTime() - new Date(a.start_date).getTime() ) setTours(sorted) }) .catch(console.error) .finally(() => setLoading(false)) }, []) if (loading) return
Loading tours...
return (

Tours

Follow the band across the country, tour by tour.

{tours.map((tour) => ( {tour.name}

{new Date(tour.start_date).toLocaleDateString()} - {new Date(tour.end_date).toLocaleDateString()}

))}
) }