MEGAINFRA-WEBAPP/src/app/api
DEIs 87f75dd98f feat(plant): fleet map page with GPS-denormalised vehicles, clustering, and tile switcher
Adds /dashboard/plant/map: a Leaflet view of every vehicle scanned from
the MEGA Clock kiosk, plotted at its last known position.

Schema
- vehicles.last_latitude / last_longitude / last_scanned_at /
  last_location_accuracy_m denormalised off fuel_logs so the map page
  renders every vehicle in a single query. Same best-effort pattern as
  attention_dismissed_at; updated by /api/clock/vehicle-scan after every
  successful scan. PB init defaults new number cols to 0 (not null) —
  filter uses 'last_latitude > 0 || last_latitude < 0' to mean 'real fix'.
- Indexed via idx_vehicles_last_scanned.

Map UI
- Custom SVG markers per unit_type: car silhouette for fuel, tractor
  silhouette for plant, 24x24, drop-shadowed.
- Clustering via react-leaflet-cluster over Leaflet.markercluster.
  Cluster icons colour-ramp with size (green->sky->amber->rose) and
  scale 32->54px.
- Three-button base-layer switcher: Street (OSM), Dark (ESRI Dark
  Gray Canvas — CartoDB watermarks tiles without a key), Satellite
  (ESRI World Imagery). Last choice persists in localStorage.
- Site pins: small purple map-marker divIcon, click flies the map to
  zoom level 15.
- Empty-state is a floating chip on the map rather than a full-page
  card so the map is always visible.

APIs
- /api/clock/vehicle-scan: stores the GPS fix on the fuel_logs row
  AND denormalises onto the vehicle when present; missing-coord
  scan leaves last_* untouched.

Sidebar: new Map entry under Plant group.
2026-09-22 21:39:25 +02:00
..
chat feat(chat): accept images in a user turn on both providers 2026-08-30 12:57:52 +02:00
clock feat(plant): fleet map page with GPS-denormalised vehicles, clustering, and tile switcher 2026-09-22 21:39:25 +02:00
data-import-batches/[id] feat(imports): return the purchase order number from batch status 2026-08-30 08:53:24 +02:00
delivery-notes fix(dn): contain bulk batch lifecycle 2026-09-18 19:32:17 +02:00
dn-batches fix(dn): settle one product line at a time, and keep the link 2026-09-21 00:15:13 +02:00
fuel-logs/import refactor(schema): resolve project_code through site, not a stored copy 2026-09-11 16:01:14 +02:00
health Refactor Purchase Order upload flow documentation 2026-08-19 02:25:11 +02:00
pb-files/[collection]/[recordId]/[...filename] fix(purchasing): proxy PB files so PDFs render in the slip iframe 2026-09-07 14:53:22 +02:00
plant-hours refactor(schema): resolve project_code through site, not a stored copy 2026-09-11 16:01:14 +02:00
purchase-orders feat(dn): grab and move the order the same way as the slip 2026-09-21 02:05:31 +02:00
records/[collection]/[id]/verify Enhance Dashboard and Sidebar Navigation 2026-08-19 01:54:16 +02:00
sites feat(sites): accept work_month_start_day on create/update 2026-09-11 22:24:59 +02:00
suppliers feat(suppliers): add create/edit API routes 2026-09-11 18:15:09 +02:00
timesheets/import refactor(schema): resolve project_code through site, not a stored copy 2026-09-11 16:01:14 +02:00
vehicles refactor(schema): resolve project_code through site, not a stored copy 2026-09-11 16:01:14 +02:00