import { useState, useEffect } from 'react'; import { Star, TrendingUp, Award } from 'lucide-react'; 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 '@/integrations/supabase/client'; 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) { console.error('Error fetching featured parks:', error); } finally { setLoading(false); } }; const FeaturedParkCard = ({ park, icon: Icon, label }: { park: Park; icon: any; 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.toFixed(1)}

{park.name}

{park.location && (

{park.location.city}, {park.location.country}

)}
{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 */}
); }