fix(badges): sync events_slct.event_id from URL param on direct navigation

The badges page relied on events_slct.event_id being set by ae_acct.slct.event_id
(populated when the user clicks an event in the events list). Direct URL navigation
— bookmark, shared link, browser history — skipped that code path, leaving
events_slct.event_id null. Any call using that value (upload form, create form)
would fire with an empty event_id and get a 404.

Reads page.params.event_id on mount, same pattern used by the launcher and
session pages, so all entry paths are reliable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-06-09 07:18:05 -04:00
parent 04f3b82d59
commit 71aacb6346

View File

@@ -17,6 +17,7 @@ import { liveQuery } from 'dexie';
// *** Import Aether specific variables and functions
import { ae_util } from '$lib/ae_utils/ae_utils';
import { ae_loc, ae_api } from '$lib/stores/ae_stores';
import { page } from '$app/state';
import { db_events } from '$lib/ae_events/db_events';
import {
@@ -34,6 +35,16 @@ import Comp_badge_upload_form from './ae_comp__badge_upload_form.svelte';
import { UserPlus, Printer, Upload, FileText, ChartColumnBig, LayoutTemplate, TrendingUp } from '@lucide/svelte';
// Sync events_slct.event_id from the URL param so direct navigation works.
// Without this, events_slct.event_id relies on ae_acct.slct.event_id (set by the
// events list) and is null if the user navigated directly to this URL.
$effect(() => {
const url_event_id = page.params.event_id;
if (url_event_id) {
untrack(() => { $events_slct.event_id = url_event_id; });
}
});
// Load templates for this event so the create form can show the selector and
// derive badge_type_code_li from whichever template the user picks.
$effect(() => {