fix(badges): add fallback badge_type_code_li when template has no badge_type_list

badge_type_code_li was returning [] when the template had no badge_type_list,
causing the Badge Type field to be hidden entirely in the Staff section.
Add same fallback default as create form and search filter.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-04-14 18:07:24 -04:00
parent 4d43fd8a67
commit deea250a85

View File

@@ -269,13 +269,27 @@ async function handle_print_badge() {
// --- Badge type list from template ---
// Each item: { code: string, name: string }. Used for the badge type dropdown.
// Falls back to a default list when the template has no badge_type_list configured.
// Keep in sync with ae_comp__badge_search.svelte and ae_comp__badge_create_form.svelte.
// TODO: drive all three from the template so this is event-agnostic.
const default_badge_type_code_li = [
{ code: 'attendee', name: 'In-Person Attendee' },
{ code: 'sponsor', name: 'Adapt26 Sponsor' },
{ code: 'staff', name: 'Staff' },
{ code: 'guest', name: 'Guest' },
{ code: 'volunteer', name: 'Volunteer' },
{ code: 'member', name: 'Member' },
{ code: 'nonmember', name: 'Non-Member' },
{ code: 'test', name: 'Test' }
];
let badge_type_code_li = $derived.by((): { code: string; name: string }[] => {
const raw = $lq__event_badge_template_obj?.badge_type_list;
if (!raw) return [];
if (!raw) return default_badge_type_code_li;
try {
return JSON.parse(raw);
const parsed = JSON.parse(raw);
return Array.isArray(parsed) && parsed.length > 0 ? parsed : default_badge_type_code_li;
} catch {
return [];
return default_badge_type_code_li;
}
});