feat: add per-event badge editor, pretix company import, smart guides

Badge Designer (admin): per-event WYSIWYG badge/PDF layout editor with mm canvas, text/QR/image elements, multi-select, Word+PowerPoint alignment, PowerPoint-style smart guides with snapping, Delete-key, preview and JSON views. Migration 20261015194531_badge_editor (badge_layouts + admin-only save/set-default/delete RPCs).

Company import: migration 20261015200719_events_company adds events.company; the sidecar pretix sync now fetches the organizer display name and stores it (best-effort). Bindable on badges as Company/organizer.

Tests: 15 SQL rollback assertions + 13 mocked browser tests. Docs synced.
This commit is contained in:
Lago committed 2026-10-15 22:25:15 +02:00
1 parent 3e2f8ff0ed
commit ab25c102dc
16 files changed
+1914 -9

No files matched your search

+4
View File
@@ -9,6 +9,7 @@ import { Sponsors } from './views/Sponsors';
import { Schedule } from './views/Schedule';
import { Activity } from './views/Activity';
import { Raffle } from './views/Raffle';
import { BadgeEditor } from './views/BadgeEditor';
import { Events } from './views/Events';
import { Interfaces } from './views/Interfaces';
import { Reports } from './views/Reports';
@@ -24,6 +25,7 @@ export type View =
| 'schedule'
| 'activity'
| 'raffle'
| 'badges'
| 'events'
| 'interfaces'
| 'reports'
@@ -37,6 +39,7 @@ const NAV: { id: View; label: string; ico: string }[] = [
{ id: 'schedule', label: 'Schedule', ico: '🗓️' },
{ id: 'activity', label: 'Activity', ico: '⚡' },
{ id: 'raffle', label: 'Raffle', ico: '🎯' },
{ id: 'badges', label: 'Badges', ico: '🎫' },
{ id: 'events', label: 'Events', ico: '📅' },
{ id: 'interfaces', label: 'Interfaces', ico: '🔌' },
{ id: 'reports', label: 'Reports', ico: '📤' },
@@ -108,6 +111,7 @@ function Shell() {
{view === 'schedule' && <Schedule />}
{view === 'activity' && <Activity />}
{view === 'raffle' && <Raffle />}
{view === 'badges' && <BadgeEditor />}
{view === 'events' && <Events />}
{view === 'interfaces' && <Interfaces />}
{view === 'reports' && <Reports />}
+42
View File
@@ -1,5 +1,7 @@
import { supabase } from './supabase';
import type {
BadgeElement,
BadgeLayout,
Checkin,
Connection,
Contact,
@@ -215,6 +217,7 @@ export async function upsertEvent(
start_date: string;
end_date: string;
location?: string | null;
company?: string | null;
sessionize_endpoint?: string | null;
pretix_organizer?: string | null;
pretix_event_slug?: string | null;
@@ -376,6 +379,45 @@ export async function resetRaffle(): Promise<void> {
await rpc('reset_raffle', {});
}
// ---- Badge editor (per-event WYSIWYG badge layout) --------------------------
/** All badge layouts for an event (default first, then by name). */
export async function getBadgeLayouts(eventId: string): Promise<BadgeLayout[]> {
const rows = await all<BadgeLayout>('badge_layouts');
return rows
.filter((r) => r.event_id === eventId)
.sort((a, b) => Number(b.is_default) - Number(a.is_default) || a.name.localeCompare(b.name));
}
/** Insert or update a layout (matched on event_id + name). */
export async function saveBadgeLayout(input: {
event_id: string;
name: string;
page_width_mm: number;
page_height_mm: number;
elements: BadgeElement[];
is_default: boolean;
}): Promise<BadgeLayout> {
return rpc<BadgeLayout>('save_badge_layout', {
p_event_id: input.event_id,
p_name: input.name,
p_page_width_mm: input.page_width_mm,
p_page_height_mm: input.page_height_mm,
p_elements: input.elements,
p_is_default: input.is_default,
});
}
/** Promote a layout to the event's default (demoting the previous one). */
export async function setDefaultBadgeLayout(id: string): Promise<void> {
await rpc('set_default_badge_layout', { p_id: id });
}
/** Delete a layout (the sole default may not be removed). */
export async function deleteBadgeLayout(id: string): Promise<void> {
await rpc('delete_badge_layout', { p_id: id });
}
// ---- Sessions: speakers, material, AI feedback -------------------------------
export async function setSessionSpeakers(sessionId: string, emails: string[]): Promise<void> {
+89
View File
@@ -59,6 +59,8 @@ export interface Event {
pretix_event_slug?: string | null;
/** Pretix API token for this event (stored in plain text, visible in settings). */
pretix_api_key?: string | null;
/** The owning organisation / company (e.g. the Pretix organizer name). */
company?: string | null;
/** When the Sessionize sync last ran for this event. */
last_synced_at: string | null;
/** Bonus points each party earns for a connection when they shared a checked-in talk (0 = off). */
@@ -152,6 +154,7 @@ export interface PretixRun {
reason?: string;
orders?: number;
attendees?: number;
company?: string | null;
skipped?: number;
summary?: PretixSyncSummary;
error?: string;
@@ -343,3 +346,89 @@ export interface RaffleWinner extends RafflePoolEntry {
draw_number: number;
drawn_at: string;
}
// ---- Badge editor (per-event WYSIWYG badge layout) --------------------------
/** A bindable attendee/event field for a text element. */
export type BadgeContentField =
| 'attendee_name'
| 'full_name'
| 'email'
| 'ticket_type'
| 'event_name'
| 'company'
| 'qr_token'
| 'static';
/** A bindable payload source for a QR element. */
export type BadgeQrValue =
| 'qr_token'
| 'checkin_url'
| 'email'
| 'attendee_name'
| 'static';
export type BadgeElementType = 'text' | 'qr' | 'image';
/** Common geometry for every badge element, in millimetres / degrees. */
export interface BadgeElementBase {
id: string;
type: BadgeElementType;
x: number;
y: number;
width: number;
height: number;
rotation: number;
}
export interface BadgeTextElement extends BadgeElementBase {
type: 'text';
content: BadgeContentField;
text: string;
font: string;
font_size: number;
line_height: number;
color: string;
bold: boolean;
italic: boolean;
align_h: 'left' | 'center' | 'right';
align_v: 'top' | 'middle' | 'bottom';
transform: 'none' | 'uppercase' | 'lowercase' | 'capitalize';
}
export interface BadgeQrElement extends BadgeElementBase {
type: 'qr';
value: BadgeQrValue;
static_value: string;
}
export interface BadgeImageElement extends BadgeElementBase {
type: 'image';
src: string;
fit: 'contain' | 'cover' | 'fill';
}
export type BadgeElement = BadgeTextElement | BadgeQrElement | BadgeImageElement;
/** A saved badge layout row from `badge_layouts`. */
export interface BadgeLayout {
id: string;
event_id: string;
name: string;
is_default: boolean;
page_width_mm: number;
page_height_mm: number;
elements: BadgeElement[];
created_at: string;
updated_at: string;
}
/** A sample attendee used to preview a layout's bound fields. */
export interface BadgeSample {
full_name: string;
email: string;
ticket_type: string;
qr_token: string;
event_name: string;
company: string;
}
+85
View File
@@ -106,6 +106,7 @@ body {
.btn.ghost { background: transparent; }
.btn.danger { background: rgba(213,0,0,.08); border-color: rgba(213,0,0,.35); color: var(--red); }
.btn.small { padding: 8px 12px; font-size: 12.5px; border-radius: 10px; }
.btn.active { background: var(--accent-soft); border-color: rgba(213,0,0,.4); color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn {
width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
@@ -389,3 +390,87 @@ table.data tr:hover td { background: rgba(244,245,249,.6); }
.sidebar-foot { display: none; }
.content { padding: 20px 16px 50px; }
}
/* ---------- Badge editor (per-event WYSIWYG layout) ---------- */
.badge-editor { display: grid; gap: 16px; }
.badge-event-pick select { min-width: 220px; }
.badge-toolbar {
display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.badge-layout-pick, .badge-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge-tools.right { margin-left: auto; }
.badge-layout-pick select { min-width: 160px; }
.badge-tool-sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
.badge-workspace { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.badge-canvas-wrap { display: grid; gap: 10px; min-width: 0; }
.badge-zoom { display: flex; align-items: center; gap: 8px; }
.badge-canvas-scroll {
overflow: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px;
padding: 28px; display: flex; justify-content: center; align-items: flex-start; min-height: 360px;
}
.badge-page {
position: relative; background: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.12); flex: none;
touch-action: none;
}
.badge-page-empty {
position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
color: #94a3b8; font-size: 13px; text-align: center; padding: 20px; pointer-events: none;
}
.badge-el { position: absolute; overflow: visible; cursor: move; }
.badge-el.selected { outline: 1.5px solid var(--accent); }
.badge-text-body { width: 100%; height: 100%; display: flex; overflow: hidden; }
.badge-text-body > span { max-width: 100%; overflow-wrap: anywhere; }
.badge-el-placeholder { color: #cbd5e1; font-style: italic; }
.badge-qr-body { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.badge-qr-body svg { width: 100%; height: 100%; }
.badge-image-body { width: 100%; height: 100%; display: block; }
.badge-image-empty {
display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 12px;
border: 1px dashed #cbd5e1; background: #f8fafc;
}
.badge-handle {
position: absolute; width: 9px; height: 9px; background: #fff; border: 1.5px solid var(--accent);
border-radius: 2px; transform: translate(-50%, -50%); z-index: 2;
}
.badge-handle-nw { left: 0; top: 0; cursor: nwse-resize; }
.badge-handle-n { left: 50%; top: 0; cursor: ns-resize; }
.badge-handle-ne { left: 100%; top: 0; cursor: nesw-resize; }
.badge-handle-e { left: 100%; top: 50%; cursor: ew-resize; }
.badge-handle-se { left: 100%; top: 100%; cursor: nwse-resize; }
.badge-handle-s { left: 50%; top: 100%; cursor: ns-resize; }
.badge-handle-sw { left: 0; top: 100%; cursor: nesw-resize; }
.badge-handle-w { left: 0; top: 50%; cursor: ew-resize; }
.badge-rotate-stem { position: absolute; left: 50%; top: -18px; width: 1.5px; height: 18px; background: var(--accent); transform: translateX(-50%); }
.badge-handle-rotate { left: 50%; top: -18px; border-radius: 50%; cursor: grab; }
.badge-props { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; position: sticky; top: 16px; }
.badge-props-head { padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.badge-props-body { padding: 14px; display: grid; gap: 12px; }
.badge-field { display: grid; gap: 5px; }
.badge-field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.badge-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.badge-color { width: 100%; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.badge-btn-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge-props-divider { height: 1px; background: var(--line); margin: 2px 0; }
.badge-json {
margin: 14px; font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
max-height: 560px; overflow: auto; color: var(--text);
}
@media (max-width: 900px) {
.badge-workspace { grid-template-columns: 1fr; }
.badge-props { position: static; }
}
/* Badge editor: alignment tools + multi-select */
.badge-props-head { display: flex; align-items: center; }
.badge-align-ref { width: auto; flex: 1; min-width: 110px; padding: 7px 10px; font-size: 12.5px; }
.badge-editor kbd {
font-family: inherit; font-size: 11px; font-weight: 700; padding: 1px 5px;
border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-2);
}
/* Badge editor: PowerPoint-style smart guides (shown while dragging) */
.badge-guide { position: absolute; pointer-events: none; z-index: 5; }
.badge-guide-v { width: 0; border-left: 1px dashed #ff2d95; }
.badge-guide-h { height: 0; border-top: 1px dashed #ff2d95; }
.badge-guide-space { border-color: #0ea5e9; }
File diff suppressed because it is too large. Load diff
+9
View File
@@ -286,6 +286,7 @@ function EventModal({
const [startDate, setStartDate] = useState(event ? event.start_date.slice(0, 10) : '');
const [endDate, setEndDate] = useState(event ? event.end_date.slice(0, 10) : '');
const [location, setLocation] = useState(event?.location ?? '');
const [company, setCompany] = useState(event?.company ?? '');
const [endpoint, setEndpoint] = useState(event?.sessionize_endpoint ?? '');
const [endpointError, setEndpointError] = useState<string | null>(null);
const [pretixApiKey, setPretixApiKey] = useState(event?.pretix_api_key ?? '');
@@ -345,6 +346,7 @@ function EventModal({
start_date: startDate,
end_date: endDate,
location: location.trim() || null,
company: company.trim() || null,
sessionize_endpoint: source,
pretix_organizer: pretixOrganizer.trim() || null,
pretix_event_slug: pretixEventSlug.trim() || null,
@@ -394,6 +396,13 @@ function EventModal({
<label>Location</label>
<input className="input" value={location} onChange={(e) => setLocation(e.target.value)} placeholder="—" />
</div>
<div className="field">
<label>Company / organizer</label>
<input className="input" value={company} onChange={(e) => setCompany(e.target.value)} placeholder="e.g. Austrian Power Platform Enthusiasts" />
<div className="muted small" style={{ marginTop: 4 }}>
The owning organisation. Auto-filled from Pretix on sync; bindable on badges.
</div>
</div>
<div className="section">
<div className="section-head">
<span className="ico">📅</span>