From d4b98227670021aca488bff0f2ec870b5c39fded Mon Sep 17 00:00:00 2001 From: Chris Sherwood Date: Wed, 20 May 2026 12:10:54 -0700 Subject: [PATCH] feat(maps): add notes input to map pin placement popup The map_markers backend has accepted a `notes` column since PR #770 and the popup display path was wired up to render it (commit 6328256), but the placement UI never got an input. Result: notes are stored, displayed when present, and impossible to actually enter via the UI. Add a notes textarea below the name input in the placement popup, thread the value through `addMarker` and `createMapMarker`, and trim + null-coalesce on save. Notes display in the marker popup on click is unchanged and now actually reachable. - admin/inertia/lib/api.ts: extend createMapMarker request type with optional notes - admin/inertia/hooks/useMapMarkers.ts: addMarker accepts and forwards notes (response already populated notes into local state, so no display-side change needed) - admin/inertia/components/maps/MapComponent.tsx: markerNotes state, textarea after name input, threaded into handleSaveMarker Edit-mode for existing markers (so users can backfill notes on already-placed pins) is intentionally out of scope here - selected-marker popup is still read-only. That's a follow-up PR if there's demand. --- .../inertia/components/maps/MapComponent.tsx | 25 +++++++++++++++++-- admin/inertia/hooks/useMapMarkers.ts | 10 ++++++-- admin/inertia/lib/api.ts | 2 +- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/admin/inertia/components/maps/MapComponent.tsx b/admin/inertia/components/maps/MapComponent.tsx index aa9d9c0..cd40cbc 100644 --- a/admin/inertia/components/maps/MapComponent.tsx +++ b/admin/inertia/components/maps/MapComponent.tsx @@ -72,6 +72,7 @@ export default function MapComponent({ const [isDraggingMap, setIsDraggingMap] = useState(false) const [placingMarker, setPlacingMarker] = useState<{ lng: number; lat: number } | null>(null) const [markerName, setMarkerName] = useState('') + const [markerNotes, setMarkerNotes] = useState('') const [markerColor, setMarkerColor] = useState('orange') const [selectedMarkerId, setSelectedMarkerId] = useState(null) @@ -153,18 +154,27 @@ export default function MapComponent({ const handleMapClick = useCallback((e: MapLayerMouseEvent) => { setPlacingMarker({ lng: e.lngLat.lng, lat: e.lngLat.lat }) setMarkerName('') + setMarkerNotes('') setMarkerColor('orange') setSelectedMarkerId(null) }, []) const handleSaveMarker = useCallback(() => { if (placingMarker && markerName.trim()) { - addMarker(markerName.trim(), placingMarker.lng, placingMarker.lat, markerColor) + const trimmedNotes = markerNotes.trim() + addMarker( + markerName.trim(), + placingMarker.lng, + placingMarker.lat, + markerColor, + trimmedNotes ? trimmedNotes : null + ) setPlacingMarker(null) setMarkerName('') + setMarkerNotes('') setMarkerColor('orange') } - }, [placingMarker, markerName, markerColor, addMarker]) + }, [placingMarker, markerName, markerNotes, markerColor, addMarker]) const handleFlyTo = useCallback((longitude: number, latitude: number) => { mapRef.current?.flyTo({ center: [longitude, latitude], zoom: 12, duration: 1500 }) @@ -317,6 +327,17 @@ export default function MapComponent({ className="block w-full rounded border border-gray-300 px-2 py-1 text-sm placeholder:text-gray-400 focus:outline-none focus:border-gray-500" /> +