import "./index.css"; import { TripDetails } from "../../../trip-planner/types"; import { useState } from "react"; export default function RestaurantsList({ tripDetails, }: { tripDetails: TripDetails; }) { // Placeholder data - ideally would come from props const [restaurants] = useState([ { id: "1", name: "The Local Grill", cuisine: "Steakhouse", priceRange: "$$", rating: 4.7, distance: "0.5 miles from center", image: "https://placehold.co/300x200?text=Restaurant1", openingHours: "5:00 PM - 10:00 PM", popular: true, }, { id: "2", name: "Ocean Breeze", cuisine: "Seafood", priceRange: "$$$", rating: 4.9, distance: "0.8 miles from center", image: "https://placehold.co/300x200?text=Restaurant2", openingHours: "12:00 PM - 11:00 PM", popular: true, }, { id: "3", name: "Pasta Paradise", cuisine: "Italian", priceRange: "$$", rating: 4.5, distance: "1.2 miles from center", image: "https://placehold.co/300x200?text=Restaurant3", openingHours: "11:30 AM - 9:30 PM", popular: false, }, { id: "4", name: "Spice Garden", cuisine: "Indian", priceRange: "$$", rating: 4.6, distance: "0.7 miles from center", image: "https://placehold.co/300x200?text=Restaurant4", openingHours: "12:00 PM - 10:00 PM", popular: false, }, ]); const [selectedId, setSelectedId] = useState(null); const [filter, setFilter] = useState(null); const selectedRestaurant = restaurants.find((r) => r.id === selectedId); const filteredRestaurants = filter ? restaurants.filter((r) => r.cuisine === filter) : restaurants; const cuisines = Array.from(new Set(restaurants.map((r) => r.cuisine))); return (

Restaurants in {tripDetails.location}

{selectedId && ( )}

For your trip {new Date(tripDetails.startDate).toLocaleDateString()} -{" "} {new Date(tripDetails.endDate).toLocaleDateString()}

{!selectedId ? (
{cuisines.map((cuisine) => ( ))}

Showing {filteredRestaurants.length} restaurants{" "} {filter ? `in ${filter}` : ""}

{filteredRestaurants.map((restaurant) => (
setSelectedId(restaurant.id)} className="border rounded-lg p-3 cursor-pointer hover:border-orange-300 hover:shadow-md transition-all" >
{restaurant.name}

{restaurant.name}

{restaurant.cuisine}

{restaurant.priceRange}
{restaurant.rating}
{restaurant.distance} {restaurant.popular && ( Popular )}
))}
) : (
{selectedRestaurant && (
{selectedRestaurant.name}

{selectedRestaurant.name}

{selectedRestaurant.cuisine}

{selectedRestaurant.priceRange}
{selectedRestaurant.rating} rating
{selectedRestaurant.distance} {selectedRestaurant.openingHours}

{selectedRestaurant.name} offers a wonderful dining experience in {tripDetails.location}. Perfect for a group of{" "} {tripDetails.numberOfGuests} guests. Enjoy authentic{" "} {selectedRestaurant.cuisine} cuisine in a relaxed atmosphere.

)}
)}
); }