Fix login hang after PIN + enrich Banquet mode
Some checks failed
Build Android APK / build-apk (push) Failing after 57m31s

- Auth: introduce a shared AuthProvider/useAuth so entering the PIN updates
  reactive state and the layout's gate navigates immediately (previously it
  cached the token check at startup, so login appeared to hang until a manual
  refresh). login/scanner now use signIn/signOut.
- Banquet: donor lookup now returns lifetime giving, last-12-months giving
  (computed from dated transactions), member/donor status, bear name, and tags.
  The banquet result screen shows status badge + lifetime and last-year figures.
  Tickets are irrelevant in banquet mode.
- Admin: fix "‹ Scanner" back link wrapping (remove fixed width).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Hank 2026-07-08 16:01:41 +00:00
parent dc39c41428
commit 1ca2c38fbf
7 changed files with 268 additions and 90 deletions

View file

@ -59,9 +59,17 @@ export async function login(pin: string): Promise<void> {
await saveToken(token);
}
// Lets the auth provider react when the token is cleared (e.g. on a 401), so
// UI state stays in sync with storage.
let onCleared: (() => void) | null = null;
export function onAuthCleared(cb: (() => void) | null): void {
onCleared = cb;
}
export async function logout(): Promise<void> {
cachedToken = null;
await clearToken();
onCleared?.();
}
async function authed<T>(path: string, init: RequestInit = {}): Promise<T> {
@ -128,9 +136,14 @@ export interface DonorLookup {
found: boolean;
email: string;
name: string;
bearName: string;
lifetime: number;
lastYear: number;
online: number;
offline: number;
total: number;
isMember: boolean;
tags: string[];
status: string;
source: "master" | "transactions" | "none";
}