Registration optionset + speaker auto-promote + welcome check-in

- registrations.type is now a Postgres ENUM (registration_type)
- session_speakers trigger auto-promotes attendee -> speaker (never overrides staff/sponsor)
- new welcome_checkin RPC: staff marks an attendee present at the event
- admin Registrations: QR token is final (no reset); failed sponsor change opens in-place sponsor lookup
- Convivo Home: Now/Next cards always render; red pending-material pill + popup for speakers
- Convivo Agenda: speakers can delete their material to re-upload
- Convivo Scan: staff Session/Welcome check-in toggle (uiverse switch)
- seed: staff (Bruno/Rita) get a password so staff QR login works after reset
This commit is contained in:
Lago committed 2026-08-23 21:33:44 +02:00
1 parent 1bffae9777
commit 1cbbd1b529
16 files changed
+730 -142

No files matched your search

+10
View File
@@ -111,6 +111,15 @@ Staff checks an attendee into a session.
> `return query` inside an `if` block would *not* terminate the function and would
> double-award.
### `welcome_checkin(p_attendee_qr)` → `(attendee_email, attendee_name, already)`
Staff **welcome** check-in: marks an attendee present at the **event** (distinct
from `checkin_attendee`, which checks someone into a specific session).
- **Role check:** `is_staff_or_admin()` or it raises `staff or admin only`.
- Resolves the attendee by `qr_token` for the active event.
- Sets `registrations.checked_in = true` (no points — that's the session
check-in's job).
- `already` is `true` if the attendee was already checked in to the event.
### `submit_feedback(p_session_id, p_rating, p_comment)` → `(feedback_id, points, earned)`
Post-session feedback.
- **Requires the caller to be checked in** to that session (else raises).
@@ -166,6 +175,7 @@ immediately.
### `set_registration_type(p_contact_email, p_type)` → `registrations`
**Admin-only.** Changes a contact's registration type for the active event.
`p_type` is `text` and is cast to the `registration_type` enum on write.
### `evaluate_session_feedback(p_session_id)` → `sessions`
**Admin-only.** The **AI-feedback stub**: sets `ai_generated_feedback` to a
+9 -1
View File
@@ -94,7 +94,7 @@ Points are scoped **per event** here (one row per contact per event).
| `id` | `uuid` PK | |
| `event_id` | `uuid` FK → `events` | `on delete cascade` |
| `contact_email` | `text` FK → `contacts` | `on delete cascade` |
| `type` | `text` | `attendee` \| `speaker` \| `staff` \| `sponsor` (default `attendee`) |
| `type` | `registration_type` (enum) | `attendee` \| `speaker` \| `staff` \| `sponsor` (default `attendee`) |
| `checked_in` | `boolean` | default `false` |
| `points` | `integer` | `>= 0`, default 0 |
| `qr_token` | `text` | nullable — the lanyard token; **doubles as the Auth password** (generated per event) |
@@ -105,6 +105,14 @@ Points are scoped **per event** here (one row per contact per event).
per event. Partial unique indexes: `registrations_external_id_uniq (external_id) WHERE external_id IS NOT NULL`
and `registrations_qr_token_uniq (qr_token) WHERE qr_token IS NOT NULL` (fast lanyard lookups).
**`type` is a Postgres ENUM** (`public.registration_type`), not free text — the
four ticket types are enforced at the database level.
**Speaker auto-promote:** the `session_speakers_speaker_promote` trigger (after
insert on `session_speakers`) promotes a contact's active-event registration from
`attendee` → `speaker` when they're added as a speaker. It is one-way (removing a
speaker never demotes) and never overrides an explicit `staff`/`sponsor` ticket.
## `sponsors` — a sponsor for an event
Unpaid sponsors are hidden from non-admins (RLS).
+36 -21
View File
@@ -42,31 +42,43 @@ Source of truth: [`supabase/seed.sql`](../../supabase/seed.sql). The seed runs o
## Demo accounts
**Attendees & staff** log in with **QR code** (typed or scanned) + **email** —
the QR token is the Auth password. The **APPE Admin** (and any staff member you
give one) can also log in with **email + password** (event-independent, so it
works for any event). The password lives in `contacts.password`; a trigger
(`trg_contact_password_sync`) **auto-syncs** it as the bcrypt hash in
`auth.users.encrypted_password`, so just set `contacts.password` in Supabase and
it works with `signInWithPassword` immediately.
**Attendees** log in with **QR code** (typed or scanned) + **email** — the QR
token is the Auth password. **Staff** log in with **QR code + their staff
password** (the Convivo app shows a password field when a staff QR is detected;
the email comes from the resolved contact). The **APPE Admin** (and any staff
member you give one) can also log in with **email + password** in the admin app
(event-independent, so it works for any event). The password lives in
`contacts.password`; a trigger (`trg_contact_password_sync`) **auto-syncs** it as
the bcrypt hash in `auth.users.encrypted_password`, so just set
`contacts.password` in Supabase and it works with `signInWithPassword`
immediately.
| Person | Type | Login | Email | Start pts |
|---|---|---|---|---|
| **Ana Silva** | attendee | QR `CVV-ANA-4821` | ana.silva@nubank.com | 40 |
| **Bruno Costa** | staff (admin) | QR `CVV-BRU-1177` | bruno.costa@acme.com | 140 |
| **Rita Lopes** | staff (admin) | QR `CVV-RIT-9034` | rita.lopes@globant.com | 95 |
| **Ana Silva** | speaker | QR `CVV-ANA-4821` | ana.silva@nubank.com | 40 |
| **Bruno Costa** | staff (admin) | QR `CVV-BRU-1177` + **password** `appe-admin-2026` | bruno.costa@acme.com | 140 |
| **Rita Lopes** | staff (admin) | QR `CVV-RIT-9034` + **password** `appe-admin-2026` | rita.lopes@globant.com | 95 |
| **APPE Admin** | staff (admin) | **password** `appe-admin-2026` | admin@appe.at | 0 |
| Tomás Ribeiro | attendee | `CVV-TOM-5566` | tomas.ribeiro@dataprev.com | 88 |
| Sofia Almeida | attendee | `CVV-SOF-2299` | sofia.almeida@loop.com | 76 |
| Marco Chen | attendee | `CVV-MRC-7712` | marco.chen@deepmind.com | 70 |
| Julia Santos | attendee | `CVV-JUL-3345` | julia.santos@ifood.com | 64 |
| Pedro Nunes | attendee | `CVV-PED-8801` | pedro.nunes@microsoft.com | 58 |
| Carla Mendes | attendee | `CVV-CAR-6623` | carla.mendes@quintoessencial.com | 52 |
| Diego Ferreira | attendee | `CVV-DIE-4458` | diego.ferreira@stone.com | 35 |
| Marina Costa | attendee | `CVV-MNA-2210` | marina.costa@olx.com | 28 |
| Lucas Oliveira | attendee | `CVV-LUC-9987` | lucas.oliveira@usp.br | 15 |
| Tomás Ribeiro | speaker | `CVV-TOM-5566` | tomas.ribeiro@dataprev.com | 88 |
| Sofia Almeida | speaker | `CVV-SOF-2299` | sofia.almeida@loop.com | 76 |
| Marco Chen | speaker | `CVV-MRC-7712` | marco.chen@deepmind.com | 70 |
| Julia Santos | speaker | `CVV-JUL-3345` | julia.santos@ifood.com | 64 |
| Pedro Nunes | speaker | `CVV-PED-8801` | pedro.nunes@microsoft.com | 58 |
| Carla Mendes | speaker | `CVV-CAR-6623` | carla.mendes@quintoessencial.com | 52 |
| Diego Ferreira | speaker | `CVV-DIE-4458` | diego.ferreira@stone.com | 35 |
| Marina Costa | speaker | `CVV-MNA-2210` | marina.costa@olx.com | 28 |
| Lucas Oliveira | speaker | `CVV-LUC-9987` | lucas.oliveira@usp.br | 15 |
| Dr. Elena Vasquez | (external speaker) | — | elena.vasquez@keynote.com | — |
> **Speaker auto-promote:** every seeded attendee who speaks in a session is
> typed `speaker` (the `session_speakers_speaker_promote` trigger promotes
> `attendee` → `speaker` on insert, so the seed states the final type). Only
> Bruno, Rita, and the APPE Admin are `staff` (the trigger never overrides an
> explicit staff/sponsor ticket).
>
> **Staff passwords:** Bruno and Rita have `contacts.password = 'appe-admin-2026'`
> so the Convivo **staff QR login** (QR + staff password) works out of the box.
> **Dr. Elena Vasquez** is an external keynote speaker: she has a `contacts` row
> (and speaks in `session_speakers`) but **no registration, no QR token, and no
> auth user**, so she can't log in — she only appears as a speaker on the agenda.
@@ -101,8 +113,11 @@ Ana (`[email protected]`) is seeded with a coherent 40-point history:
1. Log in as **Ana** (attendee) → Home, Agenda, Leaderboard all populated.
2. Scan **Marco** (`CVV-MRC-7712`) → send a connection request.
3. Log in as **Bruno** (staff) → the Scan tab becomes **Check-in** → pick a
session → scan **Carla** (`CVV-CAR-6623`) → she gets +10.
3. Log in as **Bruno** (staff) → QR `CVV-BRU-1177` + staff password
`appe-admin-2026` → the Scan tab becomes **Check-in** → pick a session → scan
**Carla** (`CVV-CAR-6623`) → she gets +10. Flip the **check-in type toggle**
to **Welcome check-in** and scan **Tomás** (`CVV-TOM-5566`) → he's marked
present at the event (no points).
4. Watch the **Leaderboard** update live (Realtime).
5. Log in as **APPE Admin** (`[email protected]` / password `appe-admin-2026`) in the
admin app → Dashboard, Contacts, Registrations, Sponsors, Schedule, Activity,
+19 -12
View File
@@ -15,7 +15,7 @@ It runs on **port 3001** (Vite dev) or as the `convivo-admin` Docker container
|---|---|
| **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`). 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). |
| **Registrations** | Per active event: list (contact, type, **QR token**, checked_in, points). Change type (enforces the sponsor rule — a failed sponsor change opens an **in-place sponsor lookup** popup), mark checked-in, **view the QR token** (final — no reset). |
| **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). |
@@ -59,7 +59,7 @@ apps/admin/src/
└─ views/
├─ Dashboard.tsx # active event + aggregates + top points + activity
├─ Contacts.tsx # table + edit / is_admin / visibility / points
├─ Registrations.tsx# per-event list + type / QR token (+reset) / checked-in
├─ Registrations.tsx# per-event list + type / QR token (view) / checked-in + sponsor lookup
├─ Sponsors.tsx # sponsor CRUD
├─ Schedule.tsx # slots + sessions + speakers + material + AI-evaluate
├─ Activity.tsx # check-ins / connections / feedback tables
@@ -79,22 +79,29 @@ 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_registration_qr_token` (regenerate a registration's lanyard
token), `adjust_points` (manual, audited as `admin`), `upsert_contact`,
- **RPCs** — `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
(AI stub), and `set_session_material` (attach uploaded material). The
`reset_registration_qr_token` RPC still exists (used by the sync path) but the
admin UI no longer exposes a token reset. See
[../backend/rpcs.md](../backend/rpcs.md).
### Resetting a QR token
### Viewing a QR token
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.
opens a modal with the scannable code. The token is **final** — it is generated by
Pretix and can't be reset from the UI (the `reset_registration_qr_token` RPC still
exists for the sync path, but the admin UI no longer exposes a reset action).
### Sponsor lookup (in-place)
Setting a registration's type to **Sponsor** requires a sponsor lookup. If none
exists for that contact, the change fails with `a sponsor registration requires a
sponsor lookup` and the UI opens an **in-place sponsor popup** (instead of just
erroring). The popup lets the admin create the sponsor (type, name, email, phone,
amount, paid) linked to that contact, then sets the registration type to
`sponsor` in one step.
### Adjusting points
+3 -1
View File
@@ -50,10 +50,12 @@ These map 1:1 to the Postgres RPCs documented in
| `createConnectionRequest(targetQr)` | `create_connection_request` | Send a connection request |
| `acceptConnection(id)` | `accept_connection` | Accept (+5 to both) |
| `rejectConnection(id)` | `reject_connection` | Decline |
| `checkinAttendee(sessionId, attendeeQr)` | `checkin_attendee` | Staff check-in (+10) |
| `checkinAttendee(sessionId, attendeeQr)` | `checkin_attendee` | Staff session check-in (+10) |
| `welcomeCheckin(attendeeQr)` | `welcome_checkin` | Staff welcome check-in (marks present at event, no points) |
| `submitFeedback(sessionId, rating, comment)` | `submit_feedback` | Rate a session (+5/+10) |
| `getLeaderboard()` | `get_leaderboard` | Active-event leaderboard |
| `uploadSessionMaterial(sessionId, file)` | `set_session_material` | Upload to `materials` bucket + set `material_path` |
| `removeSessionMaterial(sessionId)` | `set_session_material` | Delete storage object + clear `material_path` (speakers) |
| `updateMyProfile({linkedin_url, show_email, show_linkedin})` | `update_my_profile` | Self-service: set LinkedIn + visibility toggles on the caller's own contact |
### Direct table reads (RLS-scoped)
+28 -13
View File
@@ -45,12 +45,15 @@ A 3-step flow: **splash → scan → confirm**.
## Home
The landing screen. Shows:
- **Greeting + points pill** — "Good morning, Ana 👋" and `⚡ {points}` (tapping
the pill opens the Leaderboard). The event name (`event.name`) is shown under
the greeting.
- **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.
- **Greeting + pills** — "Good morning, Ana 👋" and, to the right, a **red
material pill** `📎 {n}` (only for speakers who have one or more of their
sessions without material — tapping it opens a popup listing the pending
sessions) and the **points pill** `⚡ {points}` (tapping opens the Leaderboard).
The event name (`event.name`) is shown under the greeting.
- **Now card** — **always shown** for the current slot. If the user has a pick,
the session title + a "✓ Checked in" / "Show your QR to staff to check in"
pill; otherwise a "No pick yet" placeholder (identical layout for every role).
- **Next card** — **always shown** for the next slot (pick or "No pick yet").
- **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.
- **Quick actions** — Scan & connect, Agenda, Connections, Leaderboard.
@@ -58,11 +61,14 @@ The landing screen. Shows:
Check back soon!").
> **Identical for every role.** The Home screen (and the tab bar) is the same for
> attendees and staff — no role badge, no "Check-in" relabel. Staff keep their
> check-in capability inside the **Scan** screen (Attendee/Staff mode toggle).
> attendees and staff — no role badge, no "Check-in" relabel. The Now/Next cards
> always render (with a "No pick yet" placeholder when there's no pick), so the
> layout is identical whether or not the user has picks. Staff keep their check-in
> capability inside the **Scan** screen (Attendee/Staff mode toggle).
Data: `useEvent()` (event + agenda + clock) + `getMyPreferences()` +
`getMyCheckins(email)`. Slot status comes from `slotStatus(slot, now)`
`getMyCheckins(email)` + `getMySpeakerSessions(email)` (for the pending-material
pill). Slot status comes from `slotStatus(slot, now)`
([app-structure.md#the-event-clock](./app-structure.md#the-event-clock)).
## Agenda
@@ -84,6 +90,9 @@ user speaks shows a **"🎤 you"** tag; a session with material shows a **📎**
notice is gone and a **📎 Download material** button appears (visible to **all**
attendees), pinned to the **bottom** of the sheet's button stack (below
"Pick this session").
- **Remove material** — a speaker of the session can also **🗑 Remove material**
(to re-upload). This deletes the storage object and clears `material_path` via
`set_session_material` (null) — `removeSessionMaterial`.
- Picking is "one per slot" — picking a new session in a slot replaces the old
pick (enforced by the `set_preference` RPC).
@@ -101,10 +110,16 @@ is role-aware — staff (`contact.is_admin`) default to **Staff** mode, attendee
"Connect with {name}?" sheet (with the peer's registration-type badge + LinkedIn
link if visible) → `createConnectionRequest(qr)`. Guards: can't connect with
yourself. Result toast reflects the connection status (sent / already connected).
- **Staff mode (check-in):** pick a session (dropdown grouped by slot), then scan
an attendee's lanyard → `checkinAttendee(sessionId, qr)`. Shows a result sheet:
"✓ {name} — Checked in — +10 pts · now {total}" or "⚠️ Already checked in — no
extra points" (the `already` flag from the RPC).
- **Staff mode (check-in):** a **check-in type toggle** (uiverse switch) switches
between two sub-modes:
- **Session check-in** (default) — pick a session (dropdown grouped by slot),
then scan an attendee's lanyard → `checkinAttendee(sessionId, qr)`. Shows a
result sheet: "✓ {name} — Checked in — +10 pts · now {total}" or "⚠️ Already
checked in — no extra points" (the `already` flag from the RPC).
- **Welcome check-in** — no session dropdown; scanning an attendee's lanyard →
`welcomeCheckin(qr)` marks them present at the **event**
(`registrations.checked_in = true`, no points). Result sheet: "👋 {name} —
Welcome to the event! — ✓ Checked in" (or "Already checked in to the event").
Data: `useEvent()` (for the session list) + the RPCs above.
+58 -4
View File
@@ -4,15 +4,21 @@ What's done, what's next, and the open decisions. The full roadmap lives in the
root [`roadmap.md`](../roadmap.md); this file is the working detail for the
current phase.
> **Current state:** Phases 0–8 are complete and verified, plus three polish
> **Current state:** Phases 0–8 are complete and verified, plus five polish
> rounds: **Fixes & Refinements** (QR token moved to the registration, role-pill
> capitalization, connection detail sheet + red-dot recalc, admin schedule
> speaker multi-select + upload/speaker bug fixes, sponsor contact search),
> **Admin password + profile self-service** (admin logs in with email + password;
> attendees set LinkedIn + visibility on their Profile), and **Staff exclusions
> + password sync** (setting `contacts.password` auto-syncs the Auth password;
> attendees set LinkedIn + visibility on their Profile), **Staff exclusions +
> password sync** (setting `contacts.password` auto-syncs the Auth password;
> staff excluded from the leaderboard; Home/Agenda/Profile identical for all
> roles).
> roles), **Convivo staff QR login** (a staff QR asks for the staff password, not
> an email), and **Registration optionset + speaker promote + welcome check-in**
> (`registrations.type` is now a Postgres enum; adding a speaker auto-promotes
> their registration to `speaker`; staff can do a Welcome check-in that marks an
> attendee present at the event; the admin QR token is final (no reset) and a
> failed sponsor change opens an in-place sponsor lookup; speakers see a red
> pending-material pill on Home and can delete their material to re-upload).
> Remaining work is cross-cutting (real event clock, deployment, testing) and
> the open questions in [backend/interfaces.md](./backend/interfaces.md).
@@ -304,6 +310,54 @@ browser-verified.
- Agenda session sheet: **"Download material"** moved to the **bottom** of the
button stack (below "Pick this session") with proper spacing.
## Registration optionset + speaker promote + welcome check-in — ✅ complete
Migration `20260829000000_registration_type_optionset_speaker_promote_welcome_checkin.sql`
+ app changes, all browser-verified.
**`registrations.type` is now a Postgres ENUM** (`public.registration_type`).
- The `text` column (with its old CHECK constraint + text default) is converted
to the enum; the old CHECK and default are dropped first (they can't be
auto-cast), then the enum default is set.
- The admin RPCs (`create_registration`, `set_registration_type`) take `p_type
text` and now cast it to the enum on write.
**Speaker auto-promote trigger.**
- `session_speakers_speaker_promote` (after insert on `session_speakers`)
promotes a contact's active-event registration from `attendee` → `speaker`.
One-way (removing a speaker never demotes) and never overrides an explicit
`staff`/`sponsor` ticket. The seed states the final types explicitly.
**Welcome check-in (staff).**
- New `welcome_checkin(p_attendee_qr)` RPC (staff-only): resolves the attendee by
QR for the active event and sets `registrations.checked_in = true` (no points).
- The Convivo **Scan** screen's Staff mode has a **check-in type toggle**
(uiverse switch) switching between **Session check-in** (existing dropdown +
`checkin_attendee`) and **Welcome check-in** (`welcome_checkin`).
**Admin Registrations: final QR token + in-place sponsor lookup.**
- The **Reset token** button is gone — the token is final (generated by Pretix).
The QR modal now says "This token is final…".
- Setting a type to **Sponsor** when no sponsor lookup exists opens an
**in-place sponsor popup** (create the sponsor linked to the contact, then set
the type) instead of just erroring.
**Convivo Home: always-on Now/Next + pending-material pill.**
- The **Now** and **Next** cards always render (with a "No pick yet" placeholder
when there's no pick), so the layout is identical for every role.
- Speakers with one or more sessions missing material see a **red `📎 {n}` pill**
(left of the points pill); tapping it opens a popup listing the pending
sessions. The pill disappears once every session has material.
**Convivo Agenda: speakers can delete their material.**
- A speaker of a session with material sees a **🗑 Remove material** button
(deletes the storage object + clears `material_path` via `set_session_material`
null) so they can re-upload.
**Seed: staff passwords.**
- Bruno and Rita now have `contacts.password = 'appe-admin-2026'` so the Convivo
**staff QR login** (QR + staff password) works out of the box after a reset.
## Cross-cutting / later
- **Real event clock** — replace the simulated `DEFAULT_NOW`