feat(admin): per-row badge preview with unconfigured tooltip, Excel-style column filters and search in Contacts/Registrations

- New shared BadgeRender module (resolveText/resolveQr/BadgeElementBody/BadgePagePreview/fitScale) reused by the badge editor and the new read-only preview modal
- Registrations: Badge button on every row opens a live preview of that attendee's badge; grayed out with a Uiverse-style APPE-red tooltip when the event has no badge configured
- Contacts + Registrations: per-column multi-select filters (LinkedIn/Visibility/Admin; Type/Ticket/Checked in) with Excel-style live counts, plus general search (contacts: first/last/email; registrations: +type)
- New Tooltip and ColumnFilter primitives in ui.tsx (portal-based, escape/outside-click close)
- e2e: registration-badge-preview.spec.ts (13) + table-filters.spec.ts (13), all green; docs synced

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:
committed 2026-10-16 08:53:46 +02:00
1 parent 30ed4388c0
commit 8e38052f4c
10 files changed
+988 -121

No files matched your search

+2 -88
View File
@@ -1,5 +1,4 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { QRCodeSVG } from 'qrcode.react';
import {
Copy,
Eye,
@@ -46,30 +45,11 @@ import type {
} from '../lib/types';
import { useToast } from '../context/ToastContext';
import { Empty, Spinner } from '../components/ui';
import { CONTENT_LABEL, MM, QR_LABEL, BadgeElementBody } from '../components/BadgeRender';
// CSS 96 dpi: 1mm = 3.7795px. Multiplied by the editor zoom.
const MM = 3.7795275591;
const MIN_MM = 2;
const FONTS = ['Open Sans', 'Helvetica', 'Arial', 'Georgia', 'Times New Roman', 'Courier New', 'system-ui'];
const CONTENT_LABEL: Record<BadgeTextElement['content'], string> = {
attendee_name: 'Attendee name',
full_name: 'Full name',
email: 'Email address',
ticket_type: 'Ticket type',
event_name: 'Event name',
company: 'Company / organizer',
qr_token: 'QR / badge token',
static: 'Static text',
};
const QR_LABEL: Record<BadgeQrElement['value'], string> = {
qr_token: 'QR / badge token',
checkin_url: 'Check-in URL',
email: 'Email address',
attendee_name: 'Attendee name',
static: 'Static value',
};
// Text alignment *within* an element's own box (not the box on the page).
const ALIGN_H: { v: BadgeTextElement['align_h']; label: string; Icon: typeof AlignLeft }[] = [
{ v: 'left', label: 'Align text left', Icon: AlignLeft },
@@ -220,35 +200,6 @@ const add = (a: Vec, b: Vec): Vec => ({ x: a.x + b.x, y: a.y + b.y });
const sub = (a: Vec, b: Vec): Vec => ({ x: a.x - b.x, y: a.y - b.y });
const centerOf = (e: BadgeElement): Vec => ({ x: e.x + e.width / 2, y: e.y + e.height / 2 });
// Resolve the bound content of a text element against a sample attendee.
function resolveText(el: BadgeTextElement, sample: BadgeSample): string {
let v: string;
switch (el.content) {
case 'attendee_name':
case 'full_name': v = sample.full_name; break;
case 'email': v = sample.email; break;
case 'ticket_type': v = sample.ticket_type; break;
case 'event_name': v = sample.event_name; break;
case 'company': v = sample.company; break;
case 'qr_token': v = sample.qr_token; break;
default: v = el.text;
}
if (el.transform === 'uppercase') return v.toUpperCase();
if (el.transform === 'lowercase') return v.toLowerCase();
if (el.transform === 'capitalize') return v.replace(/\b\w/g, (m) => m.toUpperCase());
return v;
}
function resolveQr(el: BadgeQrElement, sample: BadgeSample): string {
switch (el.value) {
case 'qr_token': return sample.qr_token || 'CONVIVO-QR';
case 'checkin_url': return `${window.location.origin}/checkin/${sample.qr_token || 'TOKEN'}`;
case 'email': return sample.email || '[email protected]';
case 'attendee_name': return sample.full_name || 'Attendee';
default: return el.static_value || 'https://example.com';
}
}
type Handle = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w';
const HANDLES: { id: Handle; dir: Vec; css: string }[] = [
{ id: 'nw', dir: { x: -1, y: -1 }, css: 'nw' },
@@ -872,7 +823,7 @@ function BadgeElementView({
style={style}
onPointerDown={interactive ? (e) => onMove(e, el) : undefined}
>
<ElementBody el={el} sample={sample} pxPerMm={pxPerMm} />
<BadgeElementBody el={el} sample={sample} pxPerMm={pxPerMm} />
{selected && interactive && (
<>
{HANDLES.map((h) => (
@@ -890,43 +841,6 @@ function BadgeElementView({
);
}
function ElementBody({ el, sample, pxPerMm }: { el: BadgeElement; sample: BadgeSample; pxPerMm: number }) {
if (el.type === 'text') {
const text = resolveText(el, sample);
return (
<div
className="badge-text-body"
style={{
fontFamily: `"${el.font}", sans-serif`,
fontSize: el.font_size * (pxPerMm / MM), // pt→mm→px so print scale matches
lineHeight: el.line_height,
color: el.color,
fontWeight: el.bold ? 700 : 400,
fontStyle: el.italic ? 'italic' : 'normal',
justifyContent: el.align_h === 'left' ? 'flex-start' : el.align_h === 'right' ? 'flex-end' : 'center',
alignItems: el.align_v === 'top' ? 'flex-start' : el.align_v === 'bottom' ? 'flex-end' : 'center',
textAlign: el.align_h,
}}
>
<span>{text || <span className="badge-el-placeholder">{CONTENT_LABEL[el.content]}</span>}</span>
</div>
);
}
if (el.type === 'qr') {
const size = Math.round(Math.min(el.width, el.height) * pxPerMm);
return (
<div className="badge-qr-body">
<QRCodeSVG value={resolveQr(el, sample)} size={Math.max(16, size)} level="M" marginSize={0} />
</div>
);
}
// image
if (!el.src) {
return <div className="badge-image-body badge-image-empty">Image</div>;
}
return <img className="badge-image-body" src={el.src} alt="" style={{ objectFit: el.fit }} />;
}
// ---- properties panel -------------------------------------------------------
function Num({ label, value, onChange, step = 0.1, min }: { label: string; value: number; onChange: (n: number) => void; step?: number; min?: number }) {
return (