import { useState, useEffect } from 'react'; import { Star, TrendingUp, Award, Castle, FerrisWheel, Waves, Tent, LucideIcon } from 'lucide-react'; import { formatLocationShort } from '@/lib/locationFormatter'; import { Card, CardContent } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Park } from '@/types/database'; import { supabase } from '@/lib/supabaseClient'; import { getErrorMessage } from '@/lib/errorHandler'; export function FeaturedParks() { const [topRatedParks, setTopRatedParks] = useState([]); const [mostRidesParks, setMostRidesParks] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { fetchFeaturedParks(); }, []); const fetchFeaturedParks = async () => { try { // Fetch top rated parks const { data: topRated } = await supabase .from('parks') .select(` *, location:locations(*), operator:companies!parks_operator_id_fkey(*) `) .order('average_rating', { ascending: false }) .limit(3); // Fetch parks with most rides const { data: mostRides } = await supabase .from('parks') .select(` *, location:locations(*), operator:companies!parks_operator_id_fkey(*) `) .order('ride_count', { ascending: false }) .limit(3); setTopRatedParks(topRated || []); setMostRidesParks(mostRides || []); } catch (error: unknown) { // Featured parks fetch failed - display empty sections } finally { setLoading(false); } }; const FeaturedParkCard = ({ park, icon: Icon, label }: { park: Park; icon: LucideIcon; label: string }) => (
{/* Gradient Background */}
{park.park_type === 'theme_park' ? : park.park_type === 'amusement_park' ? : park.park_type === 'water_park' ? : }
{/* Featured Badge */} {label} {/* Rating Badge */} {park.average_rating ? park.average_rating.toFixed(1) : 'N/A'}

{park.name}

{park.location && (

{formatLocationShort(park.location)}

)}
{park.ride_count} rides
{park.coaster_count}
{park.review_count} reviews
); if (loading) { return (
{[...Array(6)].map((_, i) => (
))}
); } return (

Featured Destinations

Discover the highest-rated parks and thrill capitals around the world

{/* Top Rated Parks */}

Top Rated Parks

{topRatedParks.map((park) => ( ))}
{/* Most Rides */}

Thrill Capitals

{mostRidesParks.map((park) => ( ))}
{/* Call to Action */}
); }