'use client'; import { useState } from 'react'; import { X, Star, MapPin } from 'lucide-react'; import { Restaurant, CreateRatingData } from '@/lib/api'; interface RestaurantPanelProps { restaurant: Restaurant; onClose: () => void; onAddRating: (data: CreateRatingData) => Promise; } export default function RestaurantPanel({ restaurant, onClose, onAddRating }: RestaurantPanelProps) { const [showRatingForm, setShowRatingForm] = useState(false); const [rating, setRating] = useState(5); const [review, setReview] = useState(''); const [isSubmitting, setIsSubmitting] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!review.trim()) return; setIsSubmitting(true); try { await onAddRating({ rating, review }); setShowRatingForm(false); setRating(5); setReview(''); } finally { setIsSubmitting(false); } }; return (

{restaurant.name}

{restaurant.address}

{restaurant.average_rating ? ( <> {restaurant.average_rating.toFixed(1)} ) : ( No ratings yet )}
{restaurant.total_ratings} {restaurant.total_ratings === 1 ? 'rating' : 'ratings'} {restaurant.distance && ( • {restaurant.distance < 1 ? `${Math.round(restaurant.distance * 1000)}m` : `${restaurant.distance.toFixed(1)}km`} away )}
{!showRatingForm ? ( ) : (
{[1, 2, 3, 4, 5].map((value) => ( ))}