WFDASH-WEBAPP/public
Dave c8b7e1f51b feat(rep): visit check-in PWA — phone GPS, offline outbox
The rep app: open it on site, it finds who's around you, tick who you
saw, done. Third instance of the per-route-group PWA pattern already
running here (/m boss phone, /counter), so it reuses MobileAuthGate and
gets its own manifest + service worker.

Phone GPS is the primary position source, not the vehicle tracker. The
tracker knows where the bakkie is; the phone knows where the rep is,
and those diverge by a few hundred metres once the rep walks into the
plant. GPS also needs no network, which matters because mine shafts
have poor signal. The tracker is the secondary path
(GET /api/v1/visits/position) for when location is denied or
unavailable. The independently-collected vehicle trail corroborates
check-ins afterwards, so honesty doesn't depend on the phone.

Matching runs on the phone, not the server. The app caches a compact
customer snapshot and runs rankNearbyCustomers locally, so there's one
code path that behaves identically online and off — rather than a
server path plus an offline fallback that only gets exercised in the
places it's hardest to debug.

- (rep)/rep/            layout, page, check-in view, outbox
- visits-service.ts     getCustomerSnapshot, recordVisits
- POST /api/v1/visits           record a check-in
- GET  /api/v1/visits/customers snapshot for the offline cache
- GET  /api/v1/visits/position  tracker fallback
- public/manifest-rep.json, public/sw-rep.js, pickSwPath() branch

These routes authenticate with the browser session, not AGENT_API_KEY —
the caller is a logged-in rep. The rep id comes from the validated
session rather than the request body, so a client can't log a visit as
someone else.

The outbox uses localStorage rather than IndexedDB deliberately: the
payloads are tiny and localStorage is synchronous, which matters when
the rep hits Save and immediately pockets the phone. Entries are only
removed once the server acknowledges them, so a failed flush retries
instead of dropping a visit — duplicates are preferred over loss, and
surfaced rather than merged. Permanently-rejected entries (4xx other
than 401/408/429) are dropped so one bad row can't wedge the queue.

recordVisits writes each visit independently: a stale customer id
shouldn't cost the other four visits in a queued batch.

BLOCKED until one PB admin change: rep_visits.position_source does not
yet allow "phone" — verified against the live instance, PB returns
400 "Invalid value phone". Add it to the select. Separately,
accuracy_m is silently accepted and discarded (PB ignores unknown
fields), so GPS accuracy is thrown away until that number field is
added; not blocking.

47 new tests. Verified on :4001: /rep serves 200 with the right
metadata, manifest-rep.json and sw-rep.js are served.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 21:09:27 +02:00
..
icons feat: add picking slips, bulk print tracking, supplier map 2026-07-10 10:47:11 +02:00
letterhead feat: add branded quote PDF generation and in-app viewer 2026-06-23 08:30:38 +02:00
pos fix(pos): reset stateful printer attributes per-block instead of relying on order 2026-09-04 15:58:08 +02:00
android-chrome-192x192.png feat(dashboard): add multi-theme system and supporting improvements 2026-06-26 17:59:40 +02:00
android-chrome-512x512.png feat(dashboard): add multi-theme system and supporting improvements 2026-06-26 17:59:40 +02:00
apple-touch-icon.png feat(dashboard): add multi-theme system and supporting improvements 2026-06-26 17:59:40 +02:00
favicon-16x16.png feat(dashboard): add multi-theme system and supporting improvements 2026-06-26 17:59:40 +02:00
favicon-32x32.png feat(dashboard): add multi-theme system and supporting improvements 2026-06-26 17:59:40 +02:00
favicon-96x96.png feat(dashboard): add multi-theme system and supporting improvements 2026-06-26 17:59:40 +02:00
favicon.ico feat(dashboard): add multi-theme system and supporting improvements 2026-06-26 17:59:40 +02:00
file.svg feat: add UI components for separator, sheet, sonner, switch, table, tabs, textarea, tooltip 2026-05-24 16:31:01 +02:00
globe.svg feat: add UI components for separator, sheet, sonner, switch, table, tabs, textarea, tooltip 2026-05-24 16:31:01 +02:00
manifest-counter.json feat(counter): add standalone counter order PWA 2026-08-13 09:27:20 +02:00
manifest-mobile.json fix(boss-dashboard): make /m installable as a PWA 2026-08-31 22:14:48 +02:00
manifest-rep.json feat(rep): visit check-in PWA — phone GPS, offline outbox 2026-09-06 21:09:27 +02:00
manifest.json feat(dashboard): add multi-theme system and supporting improvements 2026-06-26 17:59:40 +02:00
next.svg feat: add UI components for separator, sheet, sonner, switch, table, tabs, textarea, tooltip 2026-05-24 16:31:01 +02:00
og-image.png feat(dashboard): add multi-theme system and supporting improvements 2026-06-26 17:59:40 +02:00
og-square.png feat(dashboard): add multi-theme system and supporting improvements 2026-06-26 17:59:40 +02:00
sw-counter.js feat(counter): add standalone counter order PWA 2026-08-13 09:27:20 +02:00
sw-mobile.js feat: implement per-route service worker selection 2026-09-02 07:49:38 +02:00
sw-rep.js feat(rep): visit check-in PWA — phone GPS, offline outbox 2026-09-06 21:09:27 +02:00
sw.js chore: standardize line endings and add full test + config scaffolding 2026-06-11 20:30:02 +02:00
twitter-image.png feat(dashboard): add multi-theme system and supporting improvements 2026-06-26 17:59:40 +02:00
vercel.svg feat: add UI components for separator, sheet, sonner, switch, table, tabs, textarea, tooltip 2026-05-24 16:31:01 +02:00
wfdash-logo-icon.png chore: add logos, opencode config and build assets 2026-07-27 08:21:20 +02:00
wfdash-logo-mark.png chore: add logos, opencode config and build assets 2026-07-27 08:21:20 +02:00
wfdash-logo.png chore: add logos, opencode config and build assets 2026-07-27 08:21:20 +02:00
window.svg feat: add UI components for separator, sheet, sonner, switch, table, tabs, textarea, tooltip 2026-05-24 16:31:01 +02:00