"use client" import dynamic from "next/dynamic" import { useState, useEffect } from "react" import { motion } from "framer-motion" import Link from "next/link" import { Restaurant } from "@/app/types" const MapView = dynamic(() => import("@/app/components/MapView"), { ssr: false }) function avgRating(restaurant: Restaurant) { if (restaurant.visits.length === 0) return 0 return ( restaurant.visits.reduce((s, v) => s + v.rating, 0) / restaurant.visits.length ) } export default function MapPage() { const [restaurants, setRestaurants] = useState([]) const [loading, setLoading] = useState(true) const [selected, setSelected] = useState(null) useEffect(() => { fetch("/api/restaurants") .then((r) => r.json()) .then((data) => { setRestaurants(data) setLoading(false) }) .catch(() => setLoading(false)) }, []) return (
{/* Map */}
{loading ? (
) : ( )}
{/* Desktop sidebar */} {/* Mobile bottom sheet */}
{restaurants.map((r) => ( ))}
{selected && ( View details )}
) }