Fixes & Refinements: QR token on registration, role caps, connection detail + red dot, admin schedule/sponsors

Datamodel:
- Move qr_token from contacts to registrations (per event); new migration
  20260826000000. lanyard_lookup / create_connection_request / checkin_attendee
  resolve via registrations + active event.
- reset_qr_token -> reset_registration_qr_token (fixes ambiguous 'email' col).
- upsert_contact drops the token arg; create_registration generates + syncs it.
- Pretix sync writes the token to the registration (keeps it on re-sync).

Registration types:
- Distinct pill colors; red reserved for Staff (both apps).
- Roles capitalized everywhere (Attendee/Speaker/Sponsor/Staff); 'Attendee'
  hidden only at the Home footer.
- Reset-token button moved from Contacts to Registrations (per registration).

Sessions (APPE Admin):
- Slot types capitalized; material submitted/not-submitted state.
- Speaker selection = multi-select search dropdown.
- Fix 'a session must have a speaker' on edit (diff-based setSessionSpeakers)
  and the file-upload bug (speaker save no longer aborts first).

APPE Admin:
- Sponsors contact lookup = search field (filter + pick).

Convivo App:
- Other people's QR codes hidden; connection detail sheet shows public info +
  points.
- Connect red dot recalculates immediately on accept/decline/send.
- 'My picks today' = 2 rows (current + next); 'tap to change' links to Agenda.

Docs updated across backend + frontend.
This commit is contained in:
Lago committed 2026-08-23 10:39:21 +02:00
1 parent 005f1d404f
commit b52d8ab007
30 files changed
+1083 -232

No files matched your search

+18 -14
View File
@@ -14,10 +14,10 @@ It runs on **port 3001** (Vite dev) or as the `convivo-admin` Docker container
| View | Purpose |
|---|---|
| **Dashboard** | Active event card (name, dates, location, aggregates: avg feedback, #sessions, #speakers, #registrations, #checked-in) + top points + recent activity. |
| **Contacts** | Table of all contacts (email, name, LinkedIn, visibility toggles, `is_admin`, QR token). Edit, **reset the QR token**, toggle `is_admin`, set visibility. |
| **Registrations** | Per active event: list (contact, type, checked_in). Change type (enforces the sponsor rule), mark checked-in. |
| **Sponsors** | List (paid only visible to attendees; admin sees all). Add/edit (type, name, email, phone, paid, amount, contact lookup). |
| **Schedule** | Slots (with type) + sessions (with speakers 1:N, material upload, `average_feedback`, `ai_generated_feedback` + an **Evaluate** stub button). |
| **Contacts** | Table of all contacts (email, name, LinkedIn, visibility toggles, `is_admin`). Edit, toggle `is_admin`, set visibility, adjust points. (No QR token here — it lives on the registration.) |
| **Registrations** | Per active event: list (contact, type, **QR token**, checked_in, points). Change type (enforces the sponsor rule), mark checked-in, **view + reset the QR token** (per registration). |
| **Sponsors** | List (paid only visible to attendees; admin sees all). Add/edit (type, name, email, phone, paid, amount, **contact search-and-pick**). |
| **Schedule** | Slots (with type) + sessions (with speakers 1:N via a **multi-select search dropdown**, material upload with a **submitted / not submitted** state, `average_feedback`, `ai_generated_feedback` + an **Evaluate** stub button). |
| **Activity** | Tables of check-ins, connections, and feedback (per active event). |
| **Events** | Create event, set active (only one), edit dates/location. |
| **Interfaces** | Trigger **Pretix** and **Sessionize** syncs (per-source or "Sync all"), show the result counts, list recent sync runs, and **export the QR CSV** (name/email/type/qr_token for the active event). |
@@ -55,8 +55,8 @@ apps/admin/src/
│ └─ Login.tsx # QR + email login (admin-only)
└─ views/
├─ Dashboard.tsx # active event + aggregates + top points + activity
├─ Contacts.tsx # table + edit / QR-reset / is_admin / visibility
├─ Registrations.tsx# per-event list + type / checked-in
├─ Contacts.tsx # table + edit / is_admin / visibility / points
├─ Registrations.tsx# per-event list + type / QR token (+reset) / checked-in
├─ Sponsors.tsx # sponsor CRUD
├─ Schedule.tsx # slots + sessions + speakers + material + AI-evaluate
├─ Activity.tsx # check-ins / connections / feedback tables
@@ -76,18 +76,22 @@ key. Everything it can do is allowed by RLS:
- **Writes** — direct `insert` / `update` / `delete` on `contacts`, `events`,
`registrations`, `sponsors`, `slots`, `sessions`, and `session_speakers`
(admin-only policies).
- **RPCs** — `reset_qr_token` (regenerate a lanyard token), `adjust_points`
(manual, audited as `admin`), `upsert_contact`, `create_registration`,
`set_registration_type`, `evaluate_session_feedback` (AI stub), and
`set_session_material` (attach uploaded material). See
- **RPCs** — `reset_registration_qr_token` (regenerate a registration's lanyard
token), `adjust_points` (manual, audited as `admin`), `upsert_contact`,
`create_registration`, `set_registration_type`, `evaluate_session_feedback`
(AI stub), and `set_session_material` (attach uploaded material). See
[../backend/rpcs.md](../backend/rpcs.md).
### Resetting a QR token
`reset_qr_token(contact_email)` generates a new `CVV-XXX-NNNN` token, writes it to
`contacts.qr_token`, **re-hashes it as the Auth password** (so the old token stops
working), and deletes the contact's existing sessions (forcing a re-login). The UI
shows the new token as a scannable QR code.
The QR token lives on the **registration** (per event), not the contact. The
**Registrations** view shows each registration's token and a **QR** button that
opens a modal with the scannable code + a **Reset token** action. Reset calls
`reset_registration_qr_token(contact_email)`, which generates a new
`CVV-XXX-NNNN` token, writes it to `registrations.qr_token`, **re-hashes it as the
Auth password** (so the old token stops working), and deletes the contact's
existing sessions (forcing a re-login). The UI shows the new token as a scannable
QR code.
### Adjusting points
+3 -2
View File
@@ -37,8 +37,9 @@ Holds the Supabase **session**, the current **`Contact`**, the current
`refresh()`, `signOut()`.
> The contact is the app's source of truth for the current user's `is_admin`
> (staff powers) and `qr_token`; the registration holds the user's `type` and
> `points`. After any points-changing action, screens re-fetch.
> (staff powers); the registration holds the user's `type`, `points`, and
> `qr_token` (the lanyard token, per event). After any points-changing action,
> screens re-fetch.
## ToastContext (`context/ToastContext.tsx`)
+20 -7
View File
@@ -43,7 +43,10 @@ The landing screen. Shows:
- **Now card** — the session the user picked for the current slot, with a
"✓ Checked in" or "Show your QR to staff to check in" pill.
- **Next card** — the pick for the next slot.
- **My picks today** — the user's pick per slot (tap to change → opens Agenda).
- **My picks today** — shows only **2 rows** (the current slot's pick + the next
slot's pick). "tap to change" is a **hyperlink** to the Agenda.
- **Footer type badge** — the registration-type pill is shown **only for non-
attendee** types (Attendee is the default and is not shown at the bottom).
- **Quick actions** — Scan & connect / Check-in, Agenda, Connections, Leaderboard.
- **No active event** — a graceful empty state ("No active event right now.
Check back soon!").
@@ -98,15 +101,24 @@ Data: `useEvent()` (for the session list) + the RPCs above.
Two tabs: **My connections** and **Requests** (with a count badge).
- **My connections** — accepted connections (the other person's name +
registration type).
registration type). **Clicking a row** opens a bottom **sheet** with that
person's **public info + their points** (avatar, name, type pill, `⚡ N pts`,
LinkedIn if visible, email if `show_email`). **Other people's QR codes are
never shown.**
- **Requests** — incoming (`to_email = me`, pending) with **Accept / Decline**
buttons (`acceptConnection` / `rejectConnection`), and outgoing (`from_email =
me`, pending) shown as "Sent".
me`, pending) shown as "Sent". The person block is also clickable (same detail
sheet).
- Accepting awards +5 to both (see
[../backend/rpcs.md#accept_connectionp_connection_id--connections](../backend/rpcs.md#accept_connectionp_connection_id--connections)).
- **Live-ish:** polls every 5s while the tab is visible (`usePolling`).
- **Red dot** — any interaction with the connection logic (accept / decline / send)
dispatches a `connections-changed` window event; the Shell listens and
**recalculates the Connect red dot immediately** (it stays while any incoming
request is pending and disappears once none are). It also polls every 5s as a
fallback (`usePolling`).
Data: `getMyConnections()` + `getPublicContacts()` (to resolve names + types).
Data: `getMyConnections()` + `getPublicContacts()` (names + types) +
`getLeaderboard()` (points for the detail sheet).
## Feedback
@@ -144,8 +156,9 @@ event). The `leaderboard` table is kept in sync transactionally by the RPCs —
- **Header** — avatar, name, email, registration-type pill, a **staff** pill when
`contact.is_admin`, and a points pill.
- **My QR code** — renders `contact.qr_token` as a scannable QR (`QrImage`).
"Show this to staff for check-in and to peers to connect."
- **My QR code** — renders `registration.qr_token` (the token lives on the
registration, per event) as a scannable QR (`QrImage`). "Show this to staff for
check-in and to peers to connect."
- **Points breakdown** — sums `points_log` by category
(Session check-ins / Connections / Feedback / Other) + Total.
- **Log out** — `signOut()`.