diff --git a/src/app/cars/[id]/page.tsx b/src/app/cars/[id]/page.tsx new file mode 100644 index 0000000..740c42c --- /dev/null +++ b/src/app/cars/[id]/page.tsx @@ -0,0 +1,273 @@ +"use client"; + +import { useParams } from "next/navigation"; +import { useState } from "react"; +import { ChevronLeft, ChevronRight, Heart, Share2, MapPin, Fuel, Gauge, Calendar } from "lucide-react"; + +interface CarDetail { + id: string; + name: string; + price: string; + rating: number; + description: string; + images: Array<{ src: string; alt: string }>; + specs: { + year: string; + mileage: string; + transmission: string; + fuelType: string; + engine: string; + color: string; + }; + features: string[]; + variants?: Array<{ + label: string; + options: string[]; + selected: string; + }>; +} + +const mockCarData: { [key: string]: CarDetail } = { + "1": { + id: "1", name: "2024 Tesla Model S", price: "$89,990", rating: 5, + description: "Experience the future of electric vehicles with cutting-edge technology and exceptional performance.", images: [ + { src: "https://images.unsplash.com/photo-1560958089-b8a63dd8b50b?w=800", alt: "Tesla Model S Front" }, + { src: "https://images.unsplash.com/photo-1516814050195-3a03d82e059d?w=800", alt: "Tesla Model S Side" }, + { src: "https://images.unsplash.com/photo-1552820728-8ac41f1ce891?w=800", alt: "Tesla Model S Interior" }, + ], + specs: { + year: "2024", mileage: "5,200 miles", transmission: "Automatic", fuelType: "Electric", engine: "Dual Motor", color: "Solid Black"}, + features: [ + "Autopilot Advanced", "Premium Audio System", "Panoramic Sunroof", "19-inch Wheel Set", "Premium Interior", "Over-the-Air Updates", "Supercharger Access", "Enhanced Autopilot"], + }, + "2": { + id: "2", name: "2024 BMW M440i xDrive", price: "$67,500", rating: 5, + description: "German engineering meets performance with the new M440i xDrive.", images: [ + { src: "https://images.unsplash.com/photo-1469854523086-cc02fe5d8800?w=800", alt: "BMW M440i Front" }, + { src: "https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=800", alt: "BMW M440i Side" }, + { src: "https://images.unsplash.com/photo-1533473359331-35b3c3f0f038?w=800", alt: "BMW M440i Interior" }, + ], + specs: { + year: "2024", mileage: "8,100 miles", transmission: "Automatic", fuelType: "Gasoline", engine: "3.0L Twin-Turbo", color: "Alpine White"}, + features: [ + "M Sport Brake Package", "Premium Sound System", "Adaptive M Suspension", "20-inch M Light Alloy Wheels", "Harman Kardon Audio", "Gesture Control", "Head-Up Display", "Premium Leather Interior"], + }, +}; + +export default function CarDetailPage() { + const params = useParams(); + const carId = params.id as string; + const car = mockCarData[carId]; + const [currentImageIndex, setCurrentImageIndex] = useState(0); + const [isFavorited, setIsFavorited] = useState(false); + + if (!car) { + return ( +
+
+

Car Not Found

+

The car you're looking for doesn't exist.

+ Back to Home +
+
+ ); + } + + const nextImage = () => { + setCurrentImageIndex((prev) => (prev + 1) % car.images.length); + }; + + const prevImage = () => { + setCurrentImageIndex((prev) => (prev - 1 + car.images.length) % car.images.length); + }; + + return ( +
+
+ {/* Header */} +
+ ← Back +

{car.name}

+

{car.price}

+
+ + {/* Image Gallery */} +
+
+
+ {car.images[currentImageIndex].alt} + +
+ + {/* Navigation Buttons */} + {car.images.length > 1 && ( + <> + + + + )} + + {/* Image Counter */} +
+ {currentImageIndex + 1} / {car.images.length} +
+
+ + {/* Thumbnail Gallery */} + {car.images.length > 1 && ( +
+ {car.images.map((image, index) => ( + + ))} +
+ )} +
+ +
+ {/* Left Column - Specs & Features */} +
+ {/* Description */} +
+

Overview

+

{car.description}

+
+ + {/* Key Specifications */} +
+

Key Specifications

+
+
+
+ + Year +
+

{car.specs.year}

+
+
+
+ + Mileage +
+

{car.specs.mileage}

+
+
+
+ + Fuel Type +
+

{car.specs.fuelType}

+
+
+
+ + Transmission +
+

{car.specs.transmission}

+
+
+
+ + {/* Additional Specs */} +
+

Additional Details

+
+
+ Engine: + {car.specs.engine} +
+
+ Color: + {car.specs.color} +
+
+
+
+ + {/* Right Column - Features & CTA */} +
+ {/* Features */} +
+

Features & Amenities

+
+ {car.features.map((feature, index) => ( +
+
+ +
+ {feature} +
+ ))} +
+
+ + {/* Call to Action */} +
+ + + +
+
+
+ + {/* Related Section */} +
+

Compare Similar Vehicles

+
+ {[1, 2, 3].map((i) => ( +
+
+
+

Similar Model {i}

+

$XX,XXX

+ + View Details → + +
+
+ ))} +
+
+
+
+ ); +}