import { Card, CardContent } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { FerrisWheel } from 'lucide-react'; import { RideModel } from '@/types/database'; import { useNavigate } from 'react-router-dom'; import { getCloudflareImageUrl } from '@/lib/cloudflareImageUtils'; interface RideModelCardProps { model: RideModel; manufacturerSlug: string; } export function RideModelCard({ model, manufacturerSlug }: RideModelCardProps) { const navigate = useNavigate(); const formatCategory = (category: string | null | undefined) => { if (!category) return 'Unknown'; return category.split('_').map(word => word.charAt(0).toUpperCase() + word.slice(1) ).join(' '); }; const formatRideType = (type: string | null | undefined) => { if (!type) return 'Unknown'; return type.split('_').map(word => word.charAt(0).toUpperCase() + word.slice(1) ).join(' '); }; // Safely extract ride count and image data const extendedModel = model as RideModel & { ride_count?: number; card_image_url?: string; card_image_id?: string; }; const rideCount = extendedModel.ride_count || 0; const cardImageUrl = extendedModel.card_image_url; const cardImageId = extendedModel.card_image_id; return ( navigate(`/manufacturers/${manufacturerSlug}/models/${model.slug}`)} >
{(cardImageUrl || cardImageId) ? ( <> {model.name}
) : (
)}

{model.name}

{model.category && ( {formatCategory(model.category)} )} {model.ride_type && ( {formatRideType(model.ride_type)} )}
{rideCount > 0 && (
{rideCount} installations
)}
); }