Add park and ride pages

This commit is contained in:
gpt-engineer-app[bot]
2025-09-20 00:55:36 +00:00
parent 27a5202458
commit 90bb0216b7
6 changed files with 1058 additions and 30 deletions

487
src/pages/RideDetail.tsx Normal file
View File

@@ -0,0 +1,487 @@
import { useState, useEffect } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
import { Header } from '@/components/layout/Header';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { Separator } from '@/components/ui/separator';
import {
MapPin,
Star,
Clock,
Zap,
ArrowLeft,
Users,
Ruler,
Timer,
TrendingUp,
Camera,
Heart,
AlertTriangle
} from 'lucide-react';
import { Ride } from '@/types/database';
import { supabase } from '@/integrations/supabase/client';
export default function RideDetail() {
const { parkSlug, rideSlug } = useParams<{ parkSlug: string; rideSlug: string }>();
const navigate = useNavigate();
const [ride, setRide] = useState<Ride | null>(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
if (parkSlug && rideSlug) {
fetchRideData();
}
}, [parkSlug, rideSlug]);
const fetchRideData = async () => {
try {
// First get park to find park_id
const { data: parkData } = await supabase
.from('parks')
.select('id')
.eq('slug', parkSlug)
.maybeSingle();
if (parkData) {
// Then get ride details
const { data: rideData } = await supabase
.from('rides')
.select(`
*,
park:parks!inner(name, slug, location:locations(*)),
manufacturer:companies!rides_manufacturer_id_fkey(*),
designer:companies!rides_designer_id_fkey(*)
`)
.eq('park_id', parkData.id)
.eq('slug', rideSlug)
.maybeSingle();
setRide(rideData);
}
} catch (error) {
console.error('Error fetching ride data:', error);
} finally {
setLoading(false);
}
};
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 getRideIcon = (category: string) => {
switch (category) {
case 'roller_coaster': return '🎢';
case 'water_ride': return '🌊';
case 'dark_ride': return '🎭';
case 'flat_ride': return '🎡';
case 'kiddie_ride': return '🎠';
case 'transportation': return '🚂';
default: return '🎢';
}
};
const formatCategory = (category: string) => {
return category.split('_').map(word =>
word.charAt(0).toUpperCase() + word.slice(1)
).join(' ');
};
if (loading) {
return (
<div className="min-h-screen bg-background">
<Header />
<div className="container mx-auto px-4 py-8">
<div className="animate-pulse space-y-6">
<div className="h-64 bg-muted rounded-lg"></div>
<div className="h-8 bg-muted rounded w-1/2"></div>
<div className="h-4 bg-muted rounded w-1/3"></div>
</div>
</div>
</div>
);
}
if (!ride || !ride.park) {
return (
<div className="min-h-screen bg-background">
<Header />
<div className="container mx-auto px-4 py-8">
<div className="text-center py-12">
<h1 className="text-2xl font-bold mb-4">Ride Not Found</h1>
<p className="text-muted-foreground mb-6">
The ride you're looking for doesn't exist or has been removed.
</p>
<Button onClick={() => navigate('/rides')}>
<ArrowLeft className="w-4 h-4 mr-2" />
Back to Rides
</Button>
</div>
</div>
</div>
);
}
return (
<div className="min-h-screen bg-background">
<Header />
<main className="container mx-auto px-4 py-8">
{/* Back Button */}
<Button
variant="ghost"
onClick={() => navigate(`/parks/${ride.park?.slug}`)}
className="mb-6"
>
<ArrowLeft className="w-4 h-4 mr-2" />
Back to {ride.park?.name}
</Button>
{/* Hero Section */}
<div className="relative mb-8">
<div className="aspect-[21/9] bg-gradient-to-br from-primary/20 via-secondary/20 to-accent/20 rounded-lg overflow-hidden relative">
{ride.image_url ? (
<img
src={ride.image_url}
alt={ride.name}
className="w-full h-full object-cover"
/>
) : (
<div className="flex items-center justify-center h-full">
<div className="text-8xl opacity-50">
{getRideIcon(ride.category)}
</div>
</div>
)}
<div className="absolute inset-0 bg-gradient-to-t from-black/60 via-transparent to-transparent" />
{/* Ride Title Overlay */}
<div className="absolute bottom-0 left-0 right-0 p-8">
<div className="flex items-end justify-between">
<div>
<div className="flex items-center gap-3 mb-2">
<Badge className={`${getStatusColor(ride.status)} border`}>
{ride.status.replace('_', ' ').toUpperCase()}
</Badge>
<Badge variant="outline" className="bg-black/20 text-white border-white/20">
{formatCategory(ride.category)}
</Badge>
</div>
<h1 className="text-4xl md:text-6xl font-bold text-white mb-2">
{ride.name}
</h1>
<div className="flex items-center text-white/90 text-lg">
<MapPin className="w-5 h-5 mr-2" />
{ride.park.name}
</div>
</div>
{ride.average_rating > 0 && (
<div className="bg-black/20 backdrop-blur-sm rounded-lg p-4 text-center">
<div className="flex items-center gap-2 text-white mb-1">
<Star className="w-5 h-5 fill-yellow-400 text-yellow-400" />
<span className="text-2xl font-bold">{ride.average_rating.toFixed(1)}</span>
</div>
<div className="text-white/70 text-sm">
{ride.review_count} reviews
</div>
</div>
)}
</div>
</div>
</div>
</div>
{/* Quick Stats */}
<div className="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4 mb-8">
{ride.max_speed_kmh && (
<Card>
<CardContent className="p-4 text-center">
<Zap className="w-6 h-6 text-primary mx-auto mb-2" />
<div className="text-2xl font-bold text-primary">{ride.max_speed_kmh}</div>
<div className="text-sm text-muted-foreground">km/h</div>
</CardContent>
</Card>
)}
{ride.max_height_meters && (
<Card>
<CardContent className="p-4 text-center">
<TrendingUp className="w-6 h-6 text-accent mx-auto mb-2" />
<div className="text-2xl font-bold text-accent">{ride.max_height_meters}</div>
<div className="text-sm text-muted-foreground">meters</div>
</CardContent>
</Card>
)}
{ride.length_meters && (
<Card>
<CardContent className="p-4 text-center">
<Ruler className="w-6 h-6 text-secondary mx-auto mb-2" />
<div className="text-2xl font-bold text-secondary">{Math.round(ride.length_meters)}</div>
<div className="text-sm text-muted-foreground">meters long</div>
</CardContent>
</Card>
)}
{ride.duration_seconds && (
<Card>
<CardContent className="p-4 text-center">
<Timer className="w-6 h-6 text-primary mx-auto mb-2" />
<div className="text-2xl font-bold text-primary">{Math.floor(ride.duration_seconds / 60)}:{(ride.duration_seconds % 60).toString().padStart(2, '0')}</div>
<div className="text-sm text-muted-foreground">duration</div>
</CardContent>
</Card>
)}
{ride.capacity_per_hour && (
<Card>
<CardContent className="p-4 text-center">
<Users className="w-6 h-6 text-accent mx-auto mb-2" />
<div className="text-2xl font-bold text-accent">{ride.capacity_per_hour}</div>
<div className="text-sm text-muted-foreground">riders/hour</div>
</CardContent>
</Card>
)}
{ride.inversions && ride.inversions > 0 && (
<Card>
<CardContent className="p-4 text-center">
<div className="text-2xl mb-2">🔄</div>
<div className="text-2xl font-bold">{ride.inversions}</div>
<div className="text-sm text-muted-foreground">inversions</div>
</CardContent>
</Card>
)}
</div>
{/* Requirements & Warnings */}
{(ride.height_requirement || ride.age_requirement) && (
<Card className="mb-8 border-orange-200 bg-orange-50 dark:border-orange-800 dark:bg-orange-950">
<CardContent className="p-4">
<div className="flex items-start gap-3">
<AlertTriangle className="w-5 h-5 text-orange-600 mt-0.5" />
<div>
<h3 className="font-semibold text-orange-800 dark:text-orange-200 mb-2">
Ride Requirements
</h3>
<div className="text-sm space-y-1">
{ride.height_requirement && (
<div>Minimum height: {ride.height_requirement}cm</div>
)}
{ride.age_requirement && (
<div>Minimum age: {ride.age_requirement} years</div>
)}
</div>
</div>
</div>
</CardContent>
</Card>
)}
{/* Main Content */}
<Tabs defaultValue="overview" className="w-full">
<TabsList className="grid w-full grid-cols-4">
<TabsTrigger value="overview">Overview</TabsTrigger>
<TabsTrigger value="specs">Specifications</TabsTrigger>
<TabsTrigger value="reviews">Reviews</TabsTrigger>
<TabsTrigger value="photos">Photos</TabsTrigger>
</TabsList>
<TabsContent value="overview" className="mt-6">
<div className="grid lg:grid-cols-3 gap-6">
<div className="lg:col-span-2 space-y-6">
{/* Description */}
{ride.description && (
<Card>
<CardHeader>
<CardTitle>About {ride.name}</CardTitle>
</CardHeader>
<CardContent>
<p className="text-muted-foreground leading-relaxed">
{ride.description}
</p>
</CardContent>
</Card>
)}
</div>
<div className="space-y-6">
{/* Ride Information */}
<Card>
<CardHeader>
<CardTitle>Ride Information</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div className="flex items-center gap-3">
<div className="text-2xl">{getRideIcon(ride.category)}</div>
<div>
<div className="font-medium">Category</div>
<div className="text-sm text-muted-foreground">
{formatCategory(ride.category)}
</div>
</div>
</div>
{ride.opening_date && (
<div className="flex items-center gap-3">
<Clock className="w-4 h-4 text-muted-foreground" />
<div>
<div className="font-medium">Opened</div>
<div className="text-sm text-muted-foreground">
{new Date(ride.opening_date).getFullYear()}
</div>
</div>
</div>
)}
{ride.manufacturer && (
<div className="flex items-center gap-3">
<Users className="w-4 h-4 text-muted-foreground" />
<div>
<div className="font-medium">Manufacturer</div>
<div className="text-sm text-muted-foreground">
{ride.manufacturer.name}
</div>
</div>
</div>
)}
{ride.designer && (
<div className="flex items-center gap-3">
<Users className="w-4 h-4 text-muted-foreground" />
<div>
<div className="font-medium">Designer</div>
<div className="text-sm text-muted-foreground">
{ride.designer.name}
</div>
</div>
</div>
)}
<Separator />
<div className="space-y-2">
<div className="font-medium">Located at</div>
<Button
variant="outline"
className="w-full justify-start"
onClick={() => navigate(`/parks/${ride.park?.slug}`)}
>
<MapPin className="w-4 h-4 mr-2" />
{ride.park.name}
</Button>
</div>
</CardContent>
</Card>
</div>
</div>
</TabsContent>
<TabsContent value="specs" className="mt-6">
<div className="grid md:grid-cols-2 gap-6">
{/* Performance Stats */}
<Card>
<CardHeader>
<CardTitle>Performance</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
{ride.max_speed_kmh && (
<div className="flex justify-between">
<span>Maximum Speed</span>
<span className="font-medium">{ride.max_speed_kmh} km/h</span>
</div>
)}
{ride.max_height_meters && (
<div className="flex justify-between">
<span>Maximum Height</span>
<span className="font-medium">{ride.max_height_meters}m</span>
</div>
)}
{ride.length_meters && (
<div className="flex justify-between">
<span>Track Length</span>
<span className="font-medium">{Math.round(ride.length_meters)}m</span>
</div>
)}
{ride.duration_seconds && (
<div className="flex justify-between">
<span>Ride Duration</span>
<span className="font-medium">{Math.floor(ride.duration_seconds / 60)}:{(ride.duration_seconds % 60).toString().padStart(2, '0')}</span>
</div>
)}
{ride.inversions && ride.inversions > 0 && (
<div className="flex justify-between">
<span>Inversions</span>
<span className="font-medium">{ride.inversions}</span>
</div>
)}
</CardContent>
</Card>
{/* Operational Info */}
<Card>
<CardHeader>
<CardTitle>Operational Details</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
{ride.capacity_per_hour && (
<div className="flex justify-between">
<span>Capacity</span>
<span className="font-medium">{ride.capacity_per_hour} riders/hour</span>
</div>
)}
{ride.height_requirement && (
<div className="flex justify-between">
<span>Height Requirement</span>
<span className="font-medium">{ride.height_requirement}cm minimum</span>
</div>
)}
{ride.age_requirement && (
<div className="flex justify-between">
<span>Age Requirement</span>
<span className="font-medium">{ride.age_requirement}+ years</span>
</div>
)}
<div className="flex justify-between">
<span>Status</span>
<Badge className={getStatusColor(ride.status)}>
{ride.status.replace('_', ' ')}
</Badge>
</div>
</CardContent>
</Card>
</div>
</TabsContent>
<TabsContent value="reviews" className="mt-6">
<div className="text-center py-12">
<Star className="w-16 h-16 text-muted-foreground mx-auto mb-4" />
<h3 className="text-xl font-semibold mb-2">Reviews Coming Soon</h3>
<p className="text-muted-foreground">
User reviews and ratings will be available soon
</p>
</div>
</TabsContent>
<TabsContent value="photos" className="mt-6">
<div className="text-center py-12">
<Camera className="w-16 h-16 text-muted-foreground mx-auto mb-4" />
<h3 className="text-xl font-semibold mb-2">Photo Gallery Coming Soon</h3>
<p className="text-muted-foreground">
Photo galleries and media uploads will be available soon
</p>
</div>
</TabsContent>
</Tabs>
</main>
</div>
);
}