WFDASH-WEBAPP/src/app
Dave 7ba0b9e71f feat(visits): batch pin tool — tag every customer on a shaft at once
The single-pin tool (pick one customer, click the map, save) doesn't
scale to how the customer base actually clusters: dozens of contacts
sit at Harmony Kusasalethu, at South Deep Shaft 3, and so on. This adds
a batch counterpart at /visits/pin-tool/batch: type a site name, tick
every customer there, click the map once, and all of them get pinned.

Site is a plain free-text field on customers (Customer.site in
lib/types.ts), not a separate sites collection — simpler to add and
maintain, at the cost of relying on the office typing the name the same
way each time. The batch tool's autocomplete (backed by
listDistinctSites) and its "select everyone already tagged X" shortcut
exist specifically to curb that drift without a second collection to
manage.

- jitterCoordinates (lib/geo.ts) scatters each customer 30-80m from the
  clicked point so forty pins on one shaft render as distinct dots on
  the office map instead of one marker stacked forty deep. Bounded by
  distanceKm in tests, which is the same great-circle maths the
  check-in radius match uses.
- assignCustomersToSite / listDistinctSites (customers-service.ts) —
  the batch write and its autocomplete source. Each customer is written
  independently, mirroring recordVisits: a stale id in a forty-customer
  batch shouldn't cost the other thirty-nine.
- use-customer-list.ts extracted from pin-tool-view.tsx (verbatim, no
  behaviour change) so the batch view doesn't duplicate the fetch.
- batch-pin-helpers.ts holds the pure decisions (save-readiness order,
  filter) the same way pin-tool-helpers.ts does for the single-pin tool
  — the Leaflet-dependent view is hard to unit test directly.

Applied the "use client" + dynamic(ssr:false) lesson from the single-pin
tool's earlier 500 up front in batch/page.tsx, with a comment explaining
why it's load-bearing rather than decorative.

99 new/updated tests. Scoped verification only (geo, customers-service,
visits/*) — the wider suite currently shows unrelated failures in
quotes-service/quote-pdf-service from a change on main I did not make
and did not investigate further; none of it touches customers, geo, or
visits.

BLOCKED until one PB admin change: customers.site does not exist yet
(text field, optional). Nothing in this commit writes to it until then.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 08:30:23 +02:00
..
(app) feat(visits): batch pin tool — tag every customer on a shaft at once 2026-09-07 08:30:23 +02:00
(auth) fix: preserve destination through the login redirect 2026-09-01 15:47:27 +02:00
(counter) fix(pwa): restore apple-mobile-web-app-capable so iOS installs standalone 2026-09-06 21:56:01 +02:00
(mobile) fix(pwa): restore apple-mobile-web-app-capable so iOS installs standalone 2026-09-06 21:56:01 +02:00
(print) feat: implement discount functionality in POS system 2026-09-03 12:19:21 +02:00
(rep)/rep fix(pwa): restore apple-mobile-web-app-capable so iOS installs standalone 2026-09-06 21:56:01 +02:00
(tv)
api Add quote PDF generation and stale PDF handling 2026-09-07 07:08:27 +02:00
favicon.ico
globals.css feat: implement discount functionality in POS system 2026-09-03 12:19:21 +02:00
layout.tsx fix(pwa): restore apple-mobile-web-app-capable so iOS installs standalone 2026-09-06 21:56:01 +02:00
offline.tsx
page.tsx