diff --git a/apps/events/CHANGELOG.md b/apps/events/CHANGELOG.md index d8ab6a8..6c948c0 100644 --- a/apps/events/CHANGELOG.md +++ b/apps/events/CHANGELOG.md @@ -7,6 +7,30 @@ and this project follows [Semantic Versioning](https://semver.org/). ## [Unreleased] +## [1.50.2] - 2026-10-29 + +### Added + +- **Searchable event picker** (`components/shared/EventPicker.tsx`) instead of the plain event + dropdowns on staff and supervisor pages (scanner, event tickets, at the door, payments, manual, + email and WhatsApp attendees, forms, attendance, consent, waitlist, allocations, bundles, offline + scans, kids and volunteer set-up, manage registrations, the kiosk). It opens on upcoming events + (soonest first); past ones are behind **Show past events** (latest first), and typing searches + every event by name, campus or date. Keyboard: arrows, Page Up/Down, Enter, Escape. +- **Reports:** the events list can be searched; "Select these N" / "Clear these" act on the matches. +- **Site settings → Webhooks → How webhooks work:** what is sent and when, the envelope and + headers, retries and duplicates, checking the signature (Node.js and PHP), Zapier/Make set-up, + and a copyable example of every event type. `GET /api/outbound-webhooks` event types now carry + an `example`; `tests/webhooks.test.js` checks each one has the same shape as the real payload. + +### Changed + +- Pages that listed every event ever made in their dropdown (email and WhatsApp attendees, forms, + bundles, scanner, payments) now open on upcoming ones; their separate "Include past events" + checkboxes are gone (the picker has its own). Event tickets and Payments can now reach past + events too. +- e2e: `pickEvent()` in `e2e/fixtures.ts`; `e2e/event-picker.spec.ts`. + ## [1.50.1] - 2026-10-29 ### Added diff --git a/apps/events/FEATURES.md b/apps/events/FEATURES.md index d70ec42..967fa56 100644 --- a/apps/events/FEATURES.md +++ b/apps/events/FEATURES.md @@ -415,6 +415,12 @@ logout controls. Disconnected sessions are recovered automatically. ## Supervisor tools +- **Choosing an event** (staff and supervisor pages: scanner, event tickets, at the door, payments, + manual registration, email and WhatsApp, forms, attendance, consent, waitlist, allocations, + bundles, offline scans, kids and volunteer set-up, manage registrations, kiosk): a searchable + picker instead of a long dropdown. It opens on upcoming events, soonest first; **Show past + events** lists past ones (latest first), and typing searches every event by name, campus or date. + Arrow keys, Enter and Escape work. `components/shared/EventPicker.tsx`. - **Dashboard** — **Today** (each event or session on today: checked in so far against places, children in now, volunteers here; money in today and this week) and **Waiting for you** (unpaid registrations for the next two weeks, @@ -516,7 +522,7 @@ logout controls. Disconnected sessions are recovered automatically. ## Reports -A full-width workspace with shared filters (events, date range with presets, +A full-width workspace with shared filters (events, searchable, with "Select these N" for the matches; date range with presets, include past/inactive/closed) and a searchable grid of reports, each opening in a viewer with its own filters, stat tiles and bar charts. @@ -822,6 +828,10 @@ Site settings → **Webhooks** (admins): send what happens to other systems as i extension); rolled-back changes send nothing. Kids check-in and volunteer tickets are never sent. - https and public addresses only (DNS checked at each send, redirects not followed). Each endpoint is added to the operator register; deliveries are deleted after 30 days and with an account. +- **How webhooks work** (1.50.2), a guide on the tab (open until the first webhook is added): the + envelope and headers, retries and duplicates, checking the signature (Node.js and PHP examples), + Zapier/Make set-up, and a copyable example message for every event type. The examples come from + `EVENT_TYPES[].example` in `utils/webhooks.js`; a test keeps them the same shape as what is sent. ## Background jobs diff --git a/apps/events/WHATS-NEW.md b/apps/events/WHATS-NEW.md index bfdd592..3cf206e 100644 --- a/apps/events/WHATS-NEW.md +++ b/apps/events/WHATS-NEW.md @@ -12,6 +12,16 @@ Write for church admins, not developers: no environment variables, endpoints or developer log is CHANGELOG.md. A tagged version without a section here shows "No details given". --> +## 1.50.2 + +- **Finding an event quickly.** Wherever staff and supervisors choose an event (the scanner, at + the door, payments, messages, forms, attendance and more) there is now a search box. The list + opens on upcoming events, past ones are one click away, and typing finds any event by name, + campus or date. The events list in Reports can be searched too. +- **Webhook guide.** Site settings → Webhooks has a "How webhooks work" guide for whoever connects + another system: what is sent and when, how to check it came from you, and an example message for + every kind of event. + ## 1.50.1 - **Finding things in long lists.** The audit log can be searched by person, what was changed or diff --git a/apps/events/backend/API_DOCUMENTATION.md b/apps/events/backend/API_DOCUMENTATION.md index 4a2a0fb..5616a32 100644 --- a/apps/events/backend/API_DOCUMENTATION.md +++ b/apps/events/backend/API_DOCUMENTATION.md @@ -999,7 +999,7 @@ where v1 = HMAC-SHA256(secret, `.`). Answer 2xx within 10 s; anythi | Method | Path | Description | |--------|------|-------------| -| GET | `/api/outbound-webhooks` | Endpoints with last-week counts, and the event types | +| GET | `/api/outbound-webhooks` | Endpoints with last-week counts, and the event types (each with an `example` of its `data`) | | POST | `/api/outbound-webhooks` | `{ name, url, events }` → endpoint plus `secret` (only here) | | PUT | `/api/outbound-webhooks/:id` | `{ name?, url?, events?, isActive? }` | | DELETE | `/api/outbound-webhooks/:id` | Endpoint and its deliveries | diff --git a/apps/events/backend/package-lock.json b/apps/events/backend/package-lock.json index 65ad235..0ca566b 100644 --- a/apps/events/backend/package-lock.json +++ b/apps/events/backend/package-lock.json @@ -1,12 +1,12 @@ { "name": "event-management-backend", - "version": "1.50.1", + "version": "1.50.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "event-management-backend", - "version": "1.50.1", + "version": "1.50.2", "hasInstallScript": true, "dependencies": { "@prisma/adapter-pg": "^7.10.1", diff --git a/apps/events/backend/package.json b/apps/events/backend/package.json index 70933b9..ed1ec27 100644 --- a/apps/events/backend/package.json +++ b/apps/events/backend/package.json @@ -1,6 +1,6 @@ { "name": "event-management-backend", - "version": "1.50.1", + "version": "1.50.2", "description": "Event Management System Backend", "main": "src/index.js", "scripts": { diff --git a/apps/events/backend/src/utils/webhooks.js b/apps/events/backend/src/utils/webhooks.js index cc1f4ca..af2a77c 100644 --- a/apps/events/backend/src/utils/webhooks.js +++ b/apps/events/backend/src/utils/webhooks.js @@ -34,6 +34,48 @@ const EVENT_TYPES = [ ]; const TYPES = new Set(EVENT_TYPES.map(t => t.type)); +// What `data` looks like for each type — shown in Site settings → Webhooks so whoever builds the +// receiving side knows what arrives. tests/webhooks.test.js checks these match buildPayload. +const EXAMPLE_EVENT = { id: 'c1a2b3c4-0000-4000-8000-000000000001', title: 'Youth Camp 2026', startDate: '2026-12-04T16:00:00.000Z', endDate: '2026-12-06T12:00:00.000Z' }; +const EXAMPLE_PERSON = { id: 'u1a2b3c4-0000-4000-8000-000000000002', name: 'Thandi Mokoena', email: 'thandi@example.com', phone: '+27821234567' }; +const exampleRegistration = (status, amountPaid) => ({ + registration: { + id: 'r1a2b3c4-0000-4000-8000-000000000003', status, createdAt: '2026-10-29T08:15:00.000Z', totalDue: 1200, amountPaid, + seasonPassPurchaseId: null, + items: [{ ticket: 'Camper', variant: 'Bunk bed', quantity: 2, unitPrice: 600 }], + }, + event: EXAMPLE_EVENT, + person: EXAMPLE_PERSON, +}); +const examplePayment = (amount) => ({ + payment: { id: 'p1a2b3c4-0000-4000-8000-000000000004', amount, method: 'card', provider: 'yoco', isDonation: false, registrationId: 'r1a2b3c4-0000-4000-8000-000000000003', createdAt: '2026-10-29T08:16:00.000Z' }, + event: EXAMPLE_EVENT, + person: EXAMPLE_PERSON, +}); +const EXAMPLES = { + 'registration.created': exampleRegistration('pending', 0), + 'registration.paid': exampleRegistration('paid', 1200), + 'registration.cancelled': exampleRegistration('cancelled', 0), + 'payment.received': examplePayment(1200), + // Refunds are recorded as negative payments. + 'payment.refunded': examplePayment(-600), + 'ticket.checked_in': { + checkIn: { id: 't1a2b3c4-0000-4000-8000-000000000005', scannedAt: '2026-12-04T16:20:00.000Z', people: 1, manual: false, offline: false, session: { id: 's1a2b3c4-0000-4000-8000-000000000006', label: 'Friday evening', startsAt: '2026-12-04T16:00:00.000Z' } }, + ticket: { id: 'k1a2b3c4-0000-4000-8000-000000000007', registrationOptionId: 'o1a2b3c4-0000-4000-8000-000000000008', holderName: 'Thandi Mokoena' }, + event: EXAMPLE_EVENT, + person: EXAMPLE_PERSON, + }, + 'user.created': { person: { ...EXAMPLE_PERSON, role: 'user', createdAt: '2026-10-29T08:10:00.000Z' } }, + 'event.published': { + event: { + ...EXAMPLE_EVENT, description: 'A weekend away for grades 8–12.', location: 'Camp Joy, Magaliesburg', price: 600, + goLiveAt: '2026-10-29T06:00:00.000Z', url: 'https://events.example.org/events/c1a2b3c4-0000-4000-8000-000000000001', + campus: { name: 'North', slug: 'north' }, series: null, + }, + }, +}; +for (const t of EVENT_TYPES) t.example = EXAMPLES[t.type]; + const RETRY_AFTER_MS = [60e3, 5 * 60e3, 30 * 60e3, 2 * 3600e3, 12 * 3600e3]; const MAX_ATTEMPTS = RETRY_AFTER_MS.length + 1; const KEEP_DAYS = 30; diff --git a/apps/events/backend/tests/webhooks.test.js b/apps/events/backend/tests/webhooks.test.js index fd1fd34..a1bb35d 100644 --- a/apps/events/backend/tests/webhooks.test.js +++ b/apps/events/backend/tests/webhooks.test.js @@ -3,8 +3,12 @@ const mockDb = { webhookDelivery: { updateMany: jest.fn(), findUnique: jest.fn(), update: jest.fn(), create: jest.fn(), findMany: jest.fn(), deleteMany: jest.fn() }, user: { findUnique: jest.fn() }, registration: { findUnique: jest.fn() }, + payment: { findUnique: jest.fn() }, + ticketUsage: { findUnique: jest.fn() }, + event: { findUnique: jest.fn() }, }; jest.mock('../src/config/db', () => mockDb); +jest.mock('../src/utils/pricing', () => ({ computeRegistrationTotalDue: () => 1200 })); const crypto = require('crypto'); const webhooks = require('../src/utils/webhooks'); @@ -112,4 +116,25 @@ describe('outbound webhooks', () => { expect(made[0].eventId).toBe(made[1].eventId); expect(made[0].payload.data.person).toMatchObject({ id: 'u1', email: 't@test.local' }); }); + // The examples shown in Site settings → Webhooks must have the same shape as what is sent. + test('each event type has an example shaped like the real payload', async () => { + const shape = (v) => (v && typeof v === 'object' && !(v instanceof Date) && !Array.isArray(v) + ? Object.fromEntries(Object.keys(v).sort().map(k => [k, shape(v[k])])) + : Array.isArray(v) ? v.map(shape) : '·'); + const ev = { id: 'e1', title: 'Camp', startDate: new Date(), endDate: new Date(), kidsOptionId: null, volunteerOptionId: null }; + const user = { id: 'u1', name: 'T', email: 't@x', phoneNumber: '+27' }; + const reg = (status) => ({ id: 'r1', status, createdAt: new Date(), userId: 'u1', seasonPassPurchaseId: null, event: ev, user, payments: [{ amount: 1200 }], + registrationOptions: [{ eventOptionId: 'o1', quantity: 2, priceSnapshot: 600, eventOption: { id: 'o1', name: 'Camper' }, variant: { name: 'Bunk' }, tranches: [] }] }); + mockDb.payment.findUnique.mockResolvedValue({ id: 'p1', amount: 1200, method: 'card', provider: 'yoco', isDonation: false, registrationId: 'r1', createdAt: new Date(), userId: 'u1', user, event: ev }); + mockDb.ticketUsage.findUnique.mockResolvedValue({ id: 't1', scannedAt: new Date(), quantityRedeemed: 1, manual: false, offline: false, session: { id: 's1', label: 'Fri', startsAt: new Date() }, + ticket: { id: 'k1', userId: 'u1', registrationOptionId: 'o1', event: ev, user, holder: null, attendee: { name: 'T' }, registrationOption: { eventOptionId: 'o1' } } }); + mockDb.user.findUnique.mockResolvedValue({ ...user, role: 'user', createdAt: new Date() }); + mockDb.event.findUnique.mockResolvedValue({ ...ev, description: 'd', location: 'l', price: 600, isActive: true, isHidden: false, goLiveAt: new Date(), campus: { name: 'N', slug: 'n' }, series: null }); + for (const t of webhooks.EVENT_TYPES) { + const status = { 'registration.paid': 'paid', 'registration.cancelled': 'cancelled' }[t.type] || 'pending'; + mockDb.registration.findUnique.mockResolvedValue(reg(status)); + const built = await webhooks.buildPayload(t.type, 'x'); + expect([t.type, shape(t.example)]).toEqual([t.type, shape(built.data)]); + } + }); }); diff --git a/apps/events/docs/HANDOVER.md b/apps/events/docs/HANDOVER.md index 52c4a9c..7ee8957 100644 --- a/apps/events/docs/HANDOVER.md +++ b/apps/events/docs/HANDOVER.md @@ -1,6 +1,6 @@ # Handover — where things stand and how to carry on -Last updated: 2026-10-28, after **1.50.1** (and Hub 1.5.0). The plan itself is in +Last updated: 2026-10-29, after **1.50.2** (and Hub 1.5.0). The plan itself is in [ROADMAP-v2.md](./ROADMAP-v2.md) (decisions table at the end); the previous round of features is in [FEATURES-ROUND-1.md](./FEATURES-ROUND-1.md). @@ -14,6 +14,7 @@ encrypted settings unreadable or break existing installs. | Version | What | |---------|------| +| 1.50.2 | Searchable **event picker** (`components/shared/EventPicker.tsx`) on staff/supervisor pages and the kiosk; searchable reports events list; **How webhooks work** guide on Site settings → Webhooks (examples from `EVENT_TYPES[].example`). e2e `e2e/event-picker.spec.ts` | | 1.50.1 | Long lists: audit-log search/role filter/all actions and inclusive To date, data-request search and paging, webhook-delivery status filter and Load older, supervisor Payments loads only what it needs (`unpaid`, `userId`, `from`, `donations` filters). `components/shared/Pager.tsx`; e2e `e2e/long-lists.spec.ts` | | 1.50.0 | **Accessibility pass** (§11, WCAG 2.2 AA) on public pages, auth, registration, payment, My Events and the kiosk: skip link, focus ring, labelled fields, named quantity buttons, announced errors, `ModalOverlay` popups (focus trap, Escape), contrast and underlined in-text links, reduce-motion; Branding warns about a too-light primary colour. axe + keyboard e2e in `e2e/accessibility.spec.ts` | | 1.49.2 | **Saved filters** (§9 part 3) on registrations, users, events and reports (`/api/saved-filters`, `components/shared/SavedFilters.tsx`). Migration `20261028180000_saved_filters` | @@ -443,8 +444,21 @@ a test server (both done 2026-10-28). (`app/dashboard/admin/audit-log/page.tsx`) — the filter is built from that list. - **Still loading everything (fine for now, watch as installs grow):** user pickers that call `fetchAllUsers` (Payments, Email/WhatsApp attendees, Forms, Manual) — a server-side search - picker would replace them; event pickers using `/api/events/all?includePast=true`; the coupons - list; `GET /api/registrations` without `page` (other callers still use the plain array). + picker would replace them; the coupons list; `GET /api/registrations` without `page` (other callers still use the plain array). + +## Event picker and webhook guide (1.50.2) + +- **Choosing an event:** use `EventPicker` (`components/shared/EventPicker.tsx`), not a ` setEventFilter(e.target.value)}> - - {events.map(ev => ( - - ))} - + +