feat(scan): confirm before welcome check-in, with print warning
The staff scanner checked attendees in silently, and the default session mode never prints — so a welcome-desk scan could check someone in with no badge and no confirmation. - new read-only RPC preview_welcome_checkin(qr): resolves the attendee and reports already + will_print (mirrors the exact welcome_checkin enqueue condition: first check-in AND a layout exists). Staff/admin only; checks nobody in, enqueues nothing. - attendee Scan screen previews first and shows a Yes/No sheet: "You are checking in [Name]. By confirming, you will print this person's label." Only Yes runs welcome_checkin. Session check-in unchanged (never prints). - badge_print_tests.sql +8 assertions (109 total); ScanPage + welcome specs drive the confirm step; new CONV-CHECKIN-003 (No cancels, Yes checks in). - docs: rpcs.md, printing.md, releases/2026-10-19.md. Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
1 parent
00c89c1b48
commit
65dcf64c4e
11 files changed
+348
-7
No files matched your search
@@ -0,0 +1,54 @@
|
||||
-- -----------------------------------------------------------------------------
|
||||
-- Welcome check-in preview.
|
||||
--
|
||||
-- The staff scanner now shows a confirmation before a welcome check-in:
|
||||
-- "You are checking in [Name]. By confirming, you will print this person's
|
||||
-- label." This read-only RPC resolves a scanned QR token to the attendee and
|
||||
-- reports whether a badge would actually print, so the popup can show the real
|
||||
-- name and be honest about the print (a person already checked in, or an event
|
||||
-- without a badge layout, will NOT print — mirroring welcome_checkin exactly).
|
||||
--
|
||||
-- It does NOT check anyone in and does NOT enqueue anything; it is a pure
|
||||
-- lookup. Staff/admin only, same guard as welcome_checkin.
|
||||
-- -----------------------------------------------------------------------------
|
||||
|
||||
create or replace function public.preview_welcome_checkin(p_attendee_qr text)
|
||||
returns table (attendee_email text, attendee_name text, already boolean, will_print boolean)
|
||||
language plpgsql stable security definer set search_path = public as $$
|
||||
declare
|
||||
v_staff text := public.current_email();
|
||||
v_attendee text;
|
||||
v_name text;
|
||||
v_event_id uuid;
|
||||
v_checked boolean;
|
||||
v_reg_id uuid;
|
||||
begin
|
||||
if v_staff is null then raise exception 'not authenticated'; end if;
|
||||
if not public.is_staff_or_admin() then raise exception 'staff or admin only'; end if;
|
||||
select id into v_event_id from public.events where is_active limit 1;
|
||||
if v_event_id is null then raise exception 'no active event'; end if;
|
||||
|
||||
select r.contact_email, c.full_name, r.id into v_attendee, v_name, v_reg_id
|
||||
from public.registrations r
|
||||
join public.contacts c on c.email = r.contact_email
|
||||
where r.qr_token = p_attendee_qr
|
||||
and r.event_id = v_event_id;
|
||||
if v_attendee is null then raise exception 'no attendee found for that QR code'; end if;
|
||||
|
||||
select checked_in into v_checked
|
||||
from public.registrations
|
||||
where event_id = v_event_id and contact_email = v_attendee;
|
||||
|
||||
-- A badge prints only on a genuine first check-in AND when the event has a
|
||||
-- layout with elements (the same condition welcome_checkin uses to enqueue).
|
||||
will_print := coalesce(v_checked, false) is not true
|
||||
and public._badge_print_payload(v_reg_id, 'checkin', v_staff) is not null;
|
||||
|
||||
return query select v_attendee, v_name, coalesce(v_checked, false), will_print;
|
||||
end;
|
||||
$$;
|
||||
|
||||
revoke execute on function public.preview_welcome_checkin(text) from public, anon;
|
||||
grant execute on function public.preview_welcome_checkin(text) to authenticated;
|
||||
|
||||
notify pgrst, 'reload schema';
|
||||
Reference in new issue
Block a user