Files
thrilltrack-explorer/src/components/parks/ParkCard.tsx
2025-10-10 14:15:23 +00:00

125 lines
5.3 KiB
TypeScript

import { MapPin, Star, Users, Clock, Castle, FerrisWheel, Waves, Tent } from 'lucide-react';
import { useNavigate } from 'react-router-dom';
import { Card, CardContent } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import { Park } from '@/types/database';
import { getCloudflareImageUrl } from '@/lib/cloudflareImageUtils';
interface ParkCardProps {
park: Park;
}
export function ParkCard({ park }: ParkCardProps) {
const navigate = useNavigate();
const handleClick = () => {
navigate(`/parks/${park.slug}`);
};
const getStatusColor = (status: string) => {
switch (status) {
case 'operating':
return 'bg-green-500/20 text-green-400 border-green-500/30';
case 'seasonal':
return 'bg-yellow-500/20 text-yellow-400 border-yellow-500/30';
case 'under_construction':
return 'bg-blue-500/20 text-blue-400 border-blue-500/30';
default:
return 'bg-red-500/20 text-red-400 border-red-500/30';
}
};
const getParkTypeIcon = (type: string) => {
switch (type) {
case 'theme_park':
return <Castle className="w-5 h-5" />;
case 'amusement_park':
return <FerrisWheel className="w-5 h-5" />;
case 'water_park':
return <Waves className="w-5 h-5" />;
case 'family_entertainment':
return <Tent className="w-5 h-5" />;
default:
return <FerrisWheel className="w-5 h-5" />;
}
};
const formatParkType = (type: string) => {
return type.split('_').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
};
return <Card className="group overflow-hidden border-border/50 bg-gradient-to-br from-card via-card to-card/80 hover:shadow-2xl hover:shadow-primary/20 transition-all duration-300 cursor-pointer hover:scale-[1.02]" onClick={handleClick}>
<div className="relative overflow-hidden">
{/* Image Placeholder with Gradient */}
<div className="aspect-[4/3] bg-gradient-to-br from-primary/20 via-secondary/20 to-accent/20 flex items-center justify-center relative">
{(park.card_image_url || park.card_image_id) ? (
<img
src={park.card_image_url || getCloudflareImageUrl(park.card_image_id, 'card')}
srcSet={park.card_image_id ? `
${getCloudflareImageUrl(park.card_image_id, 'cardthumb')} 600w,
${getCloudflareImageUrl(park.card_image_id, 'card')} 1200w
` : undefined}
sizes="(max-width: 640px) 600px, 1200px"
alt={park.name}
className="w-full h-full object-cover group-hover:scale-110 transition-transform duration-500"
loading="lazy"
/>
) : (
<div className="opacity-50 flex items-center justify-center">
{getParkTypeIcon(park.park_type)}
</div>
)}
{/* Gradient Overlay */}
<div className="absolute inset-0 bg-gradient-to-t from-black/60 via-transparent to-transparent group-hover:scale-110 transition-transform duration-500" />
{/* Status Badge */}
<Badge className={`absolute top-3 right-3 ${getStatusColor(park.status)} border`}>
{park.status.replace('_', ' ').toUpperCase()}
</Badge>
</div>
<CardContent className="p-3 lg:p-3 xl:p-3.5 2xl:p-3 space-y-2 lg:space-y-2 xl:space-y-2.5">
{/* Header */}
<div className="space-y-1">
<h3 className="font-bold text-lg group-hover:text-primary transition-colors line-clamp-1">
{park.name}
</h3>
{park.location && <div className="flex items-center text-sm text-muted-foreground">
<MapPin className="w-3 h-3 mr-1" />
{park.location.city && `${park.location.city}, `}{park.location.country}
</div>}
</div>
{/* Park Type */}
<Badge variant="outline" className="text-xs">
{formatParkType(park.park_type)}
</Badge>
{/* Stats */}
<div className="flex items-center justify-between text-sm">
<div className="flex items-center gap-4">
{park.ride_count > 0 && (
<div className="flex items-center gap-1">
<span className="text-primary font-medium">{park.ride_count}</span>
<span className="text-muted-foreground">rides</span>
</div>
)}
{park.coaster_count > 0 && (
<div className="flex items-center gap-1">
<span className="text-accent font-medium">{park.coaster_count}</span>
<FerrisWheel className="w-3 h-3 text-muted-foreground" />
</div>
)}
</div>
{park.average_rating > 0 && (
<div className="flex items-center gap-1">
<Star className="w-3 h-3 fill-yellow-400 text-yellow-400" />
<span className="text-sm font-medium">{park.average_rating.toFixed(1)}</span>
{park.review_count > 0 && (
<span className="text-xs text-muted-foreground">({park.review_count})</span>
)}
</div>
)}
</div>
</CardContent>
</div>
</Card>;
}