fix: leads scanner — handle falsy API result to prevent frozen 'adding' state
When create_ae_obj__exhibit_tracking returns false/null (API down, network error, auth failure), the scanner was left frozen at 'adding' indefinitely. Added else branch to surface an error state in both single and multi scanners. Also fixes multi scanner which wasn't capturing the API return value at all. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -121,9 +121,14 @@
|
||||
// Qualify mode: navigate directly to lead detail to fill in notes/qualifiers
|
||||
goto(`/events/${page.params.event_id}/leads/exhibit/${exhibit_id}/lead/${new_tracking_id}`);
|
||||
} else {
|
||||
// Rapid mode: auto-reset after 2 seconds to scan the next person
|
||||
// Rapid/auto mode: auto-reset after 2 seconds to scan the next person
|
||||
setTimeout(reset_scanner, 2000);
|
||||
}
|
||||
} else {
|
||||
// API returned false/null — network error, API down, auth failure, or duplicate.
|
||||
// Surface the error rather than leaving the scanner frozen at 'adding'.
|
||||
scanning_status = 'error';
|
||||
error_msg = 'Failed to add lead. Check your connection and try again.';
|
||||
}
|
||||
} catch (e) {
|
||||
scanning_status = 'error';
|
||||
|
||||
@@ -177,17 +177,22 @@
|
||||
|
||||
const user_email = $events_loc.leads.auth_exhibit_kv?.[exhibit_id]?.key || 'shared_passcode';
|
||||
try {
|
||||
await events_func.create_ae_obj__exhibit_tracking({
|
||||
const result = await events_func.create_ae_obj__exhibit_tracking({
|
||||
api_cfg: $ae_api,
|
||||
exhibit_id,
|
||||
event_badge_id: item.badge.event_badge_id_random,
|
||||
external_person_id: user_email,
|
||||
group: user_email
|
||||
});
|
||||
item.status = 'added';
|
||||
if (on_lead_added) on_lead_added(item.badge);
|
||||
// Brief success display, then fade out
|
||||
setTimeout(() => dismiss_item(item), 1000);
|
||||
if (result) {
|
||||
item.status = 'added';
|
||||
if (on_lead_added) on_lead_added(item.badge);
|
||||
// Brief success display, then fade out
|
||||
setTimeout(() => dismiss_item(item), 1000);
|
||||
} else {
|
||||
// API returned false/null — network error, API down, or auth failure.
|
||||
item.status = 'error';
|
||||
}
|
||||
} catch {
|
||||
item.status = 'error';
|
||||
}
|
||||
@@ -299,7 +304,7 @@
|
||||
<div class="w-full grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||
{#each batch as item (item.id)}
|
||||
<div
|
||||
class="batch-card card p-4 space-y-3 bg-surface-50-900 border border-surface-500/20 shadow min-h-[7rem]"
|
||||
class="batch-card card p-4 space-y-3 bg-surface-50-900 border border-surface-500/20 shadow min-h-28"
|
||||
class:dismissing={item.dismissing}
|
||||
>
|
||||
{#if item.status === 'loading'}
|
||||
|
||||
Reference in New Issue
Block a user