Skip to content

feat(dashboard): geographic map with pins for all reports#69

Merged
eliaschikwanda merged 1 commit into
feat/dashboard-report-detailsfrom
feat/dashboard-reports-map
May 22, 2026
Merged

feat(dashboard): geographic map with pins for all reports#69
eliaschikwanda merged 1 commit into
feat/dashboard-report-detailsfrom
feat/dashboard-reports-map

Conversation

@davidlu468
Copy link
Copy Markdown
Contributor

Summary

Adds a geographic map to the dashboard showing every report with valid coordinates as a pin, sitting between the stats tiles and the report list.

  • Library: Leaflet 1.9 + OpenStreetMap/CARTO Positron tiles (free, no API key in the browser).
  • Why not Google Maps: the existing GOOGLE_MAPS_API_KEY in the repo is an unrestricted server-side key used by /api/location/suggest. Exposing it via NEXT_PUBLIC_* would let anyone scrape it from the client bundle. The OSM/CARTO path is consistent with the Nominatim fallback already used in that route.
  • Client-only: Leaflet touches window, so the component is "use client" and the library is dynamically imported inside useEffect. The Leaflet CSS is a static client-side import that Next.js bundles normally.
  • Pins: custom SVG divIcon markers colored to match the existing status pill palette — purple (#9b87f5) for draft/classifying, green (#22c55e) for confirmed and beyond.
  • Camera: setView at zoom 14 for a single pin, fitBounds with padding for multiple.
  • Popups: click a pin to see issue type, short address, status pill, and relative time, all styled with the app's design tokens (--card, --border, --ep-green-light, --ep-purple-light) so they feel native.

Reports without finite latitude/longitude are silently skipped; the map only renders when at least one mappable point exists.

Stacking note

Based on feat/dashboard-report-details (#68) because it builds on the same dashboard refactor (reuses ISSUE_TYPE_LABELS, shortenAddress, and the new dashboard layout). Once #68 merges, please retarget this PR to main.

Files changed

  • nexa/src/components/dashboard/reports-map.tsx — new client component
  • nexa/src/app/dashboard/page.tsx — selects latitude/longitude, builds mapPoints, renders <ReportsMap />
  • nexa/src/app/globals.css — Leaflet popup/pin styling that matches ep-card
  • nexa/package.json / package-lock.json — adds leaflet and @types/leaflet

Test plan

  • npm run lint — clean (verified locally: only pre-existing <img> warnings unrelated to this change)
  • tsc --noEmit — clean (verified locally)
  • Visit /dashboard with at least one report that has coordinates — map renders, pin appears at the right location
  • Visit /dashboard with no geocoded reports — map is hidden, stats and report list unaffected
  • Submit multiple reports in different cities — bounds auto-fit to include all pins
  • Click a pin — popup shows issue type, address, status pill (green for confirmed, neutral for draft), and relative time
  • Resize window / open on mobile — map height (360px) and controls remain usable

Made with Cursor

Adds a Leaflet-powered map between the stats row and report list that
plots every report with valid coordinates. Pins use the app's purple/
green palette to mirror status pill colors, and clicking a pin opens a
popup with issue type, short address, status, and relative time.

Uses free OpenStreetMap/CARTO tiles rather than the server-side Google
Maps key so the unrestricted API key stays out of the browser bundle.
Leaflet is loaded only on the client (dynamic import in useEffect) to
avoid SSR access to `window`.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nexa Ready Ready Preview, Comment May 21, 2026 1:32am

@davidlu468 davidlu468 requested a review from eliaschikwanda May 21, 2026 01:39
@eliaschikwanda eliaschikwanda merged commit e94fa34 into feat/dashboard-report-details May 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants