'use client' import { MapContainer, TileLayer, Marker, Popup } from 'react-leaflet' import L from 'leaflet' import 'leaflet/dist/leaflet.css' import { Link } from '@/i18n/routing' export interface MapListing { id: string slug: string name: string categorySlug: string categoryName: string latitude: number longitude: number isLocalApproved: boolean image?: string } function buildPinIcon(color: string) { return L.divIcon({ className: '', html: ` `, iconSize: [28, 36], iconAnchor: [14, 34], popupAnchor: [0, -32], }) } const approvedIcon = buildPinIcon('#E8A23D') const defaultIcon = buildPinIcon('#2E9C9A') interface ListingsMapProps { listings: MapListing[] approvedLabel: string viewLabel: string } export default function ListingsMap({ listings, approvedLabel, viewLabel }: ListingsMapProps) { if (listings.length === 0) return null const center: [number, number] = [ listings.reduce((sum, l) => sum + l.latitude, 0) / listings.length, listings.reduce((sum, l) => sum + l.longitude, 0) / listings.length, ] return ( {listings.map((listing) => ( {listing.isLocalApproved && ( {approvedLabel} )} {listing.name} {listing.categoryName} {viewLabel} → ))} ) }