diff --git a/src/routes/events/[event_id]/(badges)/badges/ae_comp__badge_create_form.svelte b/src/routes/events/[event_id]/(badges)/badges/ae_comp__badge_create_form.svelte index 99dc57e2..3e057a3c 100644 --- a/src/routes/events/[event_id]/(badges)/badges/ae_comp__badge_create_form.svelte +++ b/src/routes/events/[event_id]/(badges)/badges/ae_comp__badge_create_form.svelte @@ -41,12 +41,14 @@ let email: string = $state(''); let allow_tracking: boolean = $state(false); let badge_type_code: string = $state(''); -// Auto-select the first template when only one is available; otherwise let the user pick. -// event_badge_template_id is sent to the API so the badge renders with the correct layout. +// Always pre-select the first template. Every badged event must have at least one template — +// without one the badge cannot render. If there's only one we auto-select silently; if there +// are multiple the dropdown lets the user switch, but we never start with no selection. +// The !selected_template_id guard prevents a reactive re-fire from overriding a user's pick. let selected_template_id: string = $state(''); $effect(() => { - if (template_li.length === 1 && template_li[0].event_badge_template_id) { - selected_template_id = template_li[0].event_badge_template_id; + if (template_li.length >= 1 && !selected_template_id) { + selected_template_id = template_li[0].event_badge_template_id ?? ''; } }); @@ -214,13 +216,17 @@ let step_label = $derived( Email - {#if template_li.length > 1} + {#if template_li.length === 0} + +

+ No badge templates are configured for this event. Set up a template before creating badges. +

+ {:else if template_li.length > 1} + Single-template events auto-select silently; the selector would just add noise. -->