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

+32 -8
View File
@@ -178,6 +178,19 @@ async function fetchPretixItems(organizer, eventSlug, apiKey) {
return names;
}
// Pretix `name` fields are localized objects ({ en, de, ... }) or plain strings.
function pickPretixName(n) {
if (!n) return '';
if (typeof n === 'string') return n;
return n.en || n.de || n['*'] || Object.values(n)[0] || '';
}
// Fetch the organizer's display name (the owning company / organisation).
async function fetchPretixOrganizerName(organizer, apiKey) {
const org = await pretixFetch(`/organizers/${encodeURIComponent(organizer)}/`, { apiKey });
return pickPretixName(org && org.name) || '';
}
// List the key's organizers, and for each organizer its events (active only).
// Used by the admin "paste the API key" flow to populate the organizer +
// event-slug dropdowns from real data.
@@ -189,18 +202,12 @@ async function fetchPretixOptions(apiKey) {
`/organizers/${encodeURIComponent(org.slug)}/events/?is_active=true`,
{ apiKey },
);
// Pretix `name` fields are localized objects ({ en, de, ... }) or strings.
const pickName = (n) => {
if (!n) return '';
if (typeof n === 'string') return n;
return n.en || n.de || n['*'] || Object.values(n)[0] || '';
};
out.push({
slug: org.slug,
name: pickName(org.name) || org.slug,
name: pickPretixName(org.name) || org.slug,
events: (events.results || []).map((e) => ({
slug: e.slug,
name: pickName(e.name) || e.slug,
name: pickPretixName(e.name) || e.slug,
})),
});
}
@@ -467,6 +474,22 @@ async function runPretixSync(eventId) {
body: { p_event_id: event.id, p_attendees: attendees },
});
// Pull the organizer's display name (the owning company) and store it on the
// event so badges can bind a "Company / organizer" field. Best-effort: a
// failure here must not fail the attendee sync that already succeeded.
let company = null;
try {
company = await fetchPretixOrganizerName(event.pretix_organizer, apiKey);
if (company) {
await supabaseFetch(`/rest/v1/events?id=eq.${encodeURIComponent(event.id)}`, {
method: 'PATCH',
body: { company },
});
}
} catch (err) {
log('pretix: company fetch failed', { eventId: event.id, error: err.message });
}
const finishedAt = new Date().toISOString();
const result = {
event_id: event.id,
@@ -476,6 +499,7 @@ async function runPretixSync(eventId) {
status: 'success',
orders: orders.length,
attendees: attendees.length,
company,
skipped,
summary,
};