feat: event lead capture (change 4a) #7

Merged
ngqile merged 14 commits from add-event-lead-capture into main 2026-11-27 06:21:39 +00:00
Owner

Summary

Implements OpenSpec change add-event-lead-capture: interests, and capturing leads at events from a phone.

  • Database (service-counter): lead, event_lead, interest and event_lead_interest tables, plus the BO_EVENT_LEADS and BO_INTERESTS modules. The SQL is in the change folder and mirrored in local/seed/03-colite.sql.
  • services-counter: interest list; lead matching; a transactional capture that fills only the lead's blank fields (ALREADY_CAPTURED 409 carries the existing eventLeadUuid); the event leads listing with filters; the event lead edit.
  • mobile-api: /api/admin/interests and /api/admin/event-leads/**.
    • Mobile numbers are normalised with libphonenumber (Malaysia by default); emails are trimmed and lowercased.
    • The salesperson must be on the event's team; an unchanged value may stay.
    • Only enabled events take leads, and inactive interests can't be newly added.
  • Admin portal:
    • an Interests screen;
    • one proxy route for event leads, which rejects . and .. path segments;
    • the event picker;
    • the listing (a table on wide screens, cards on phones);
    • a two-step key-in form (match first, then details);
    • the event lead edit page.

Verification

  • mvn -T 1C verify for mobile-api and services-counter: 544 tests, 0 failures.
  • Portal: vitest 143 files / 1081 tests, tsc ok, lint has 0 errors (4 warnings that were already there), next build ok.
  • openspec validate add-event-lead-capture --strict passes.
  • Every task passed an Opus review gate, and a final whole-branch review returned READY.
  • Playwright on the local stack, at desktop width and at 360×780 (no sideways scroll):
    • capturing a new lead;
    • the same mobile in another format at a second event, matched as EXISTING with its blank email filled;
    • a different person with the same mobile;
    • the already-captured case;
    • the invalid mobile and missing contact errors;
    • an off-team salesperson refused (NOT_ON_TEAM, through the API);
    • the listing filters and the edit page;
    • a user without the modules sees "Not authorised", and the API returns 403.

Known gaps and follow-ups

  • The change-3 event table has no company_id, so event lookups are not limited to one company. This is recorded in design.md and should be fixed with the multi-company move.
  • The EventLeadRepository.search and findMatches queries are proven only by the live MySQL check. A @DataJpaTest with Testcontainers would cover them.
  • Salesperson names are fetched with one /user/findById call per team member. Teams are small, so this is fine for now.
  • Two EXISTING captures of the same lead at the same moment could lose one blank-field fill.
  • Lead Listing, lead detail and CSV exports are change 4b.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM

## Summary Implements OpenSpec change `add-event-lead-capture`: interests, and capturing leads at events from a phone. - **Database** (`service-counter`): `lead`, `event_lead`, `interest` and `event_lead_interest` tables, plus the `BO_EVENT_LEADS` and `BO_INTERESTS` modules. The SQL is in the change folder and mirrored in `local/seed/03-colite.sql`. - **services-counter**: interest list; lead matching; a transactional capture that fills only the lead's blank fields (`ALREADY_CAPTURED` 409 carries the existing `eventLeadUuid`); the event leads listing with filters; the event lead edit. - **mobile-api**: `/api/admin/interests` and `/api/admin/event-leads/**`. - Mobile numbers are normalised with libphonenumber (Malaysia by default); emails are trimmed and lowercased. - The salesperson must be on the event's team; an unchanged value may stay. - Only enabled events take leads, and inactive interests can't be newly added. - **Admin portal**: - an Interests screen; - one proxy route for event leads, which rejects `.` and `..` path segments; - the event picker; - the listing (a table on wide screens, cards on phones); - a two-step key-in form (match first, then details); - the event lead edit page. ## Verification - `mvn -T 1C verify` for mobile-api and services-counter: 544 tests, 0 failures. - Portal: vitest 143 files / 1081 tests, `tsc` ok, lint has 0 errors (4 warnings that were already there), `next build` ok. - `openspec validate add-event-lead-capture --strict` passes. - Every task passed an Opus review gate, and a final whole-branch review returned READY. - Playwright on the local stack, at desktop width and at 360×780 (no sideways scroll): - capturing a new lead; - the same mobile in another format at a second event, matched as EXISTING with its blank email filled; - a different person with the same mobile; - the already-captured case; - the invalid mobile and missing contact errors; - an off-team salesperson refused (`NOT_ON_TEAM`, through the API); - the listing filters and the edit page; - a user without the modules sees "Not authorised", and the API returns 403. ## Known gaps and follow-ups - The change-3 `event` table has no `company_id`, so event lookups are not limited to one company. This is recorded in `design.md` and should be fixed with the multi-company move. - The `EventLeadRepository.search` and `findMatches` queries are proven only by the live MySQL check. A `@DataJpaTest` with Testcontainers would cover them. - Salesperson names are fetched with one `/user/findById` call per team member. Teams are small, so this is fine for now. - Two EXISTING captures of the same lead at the same moment could lose one blank-field fill. - Lead Listing, lead detail and CSV exports are change 4b. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
ngqile added 14 commits 2026-11-27 06:21:36 +00:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Lists, adds, renames, orders and activates/deactivates interests,
gated by BO_INTERESTS. API errors map to field messages under Name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
One proxy route for /api/admin/event-leads (dot segments rejected),
service, types, and /event-leads gated by BO_EVENT_LEADS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Picker lists events with those running today first. The listing filters
by salesperson, temperature, status, interest and lead type, with a
table at md and up and tappable cards on phones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Step 1 matches on mobile or email and offers each candidate (or opens an
already-captured one). Step 2 captures a new or picked lead with
salesperson, temperature, status, interests and follow-up date. A picked
lead only gets contact values that are its own, so no two people merge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Edits salesperson, temperature, status, interests, follow-up date and
notes. An off-team current salesperson and an inactive interest already
on the lead stay selectable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
The picker tests waited only for the load call, then read the cards
before they rendered, which failed intermittently in the full suite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
ngqile merged commit 21e4feabf0 into main 2026-11-27 06:21:39 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ngqile/co-lite#7