Admin hub in /crush33: sidebar, donor lookup, danger-zone actions
Rebuilt the password-gated /crush33 (in-app /comp) screen into an admin
hub with a left sidebar and three sections:
- Comp tickets — the existing entry-only comp creator.
- Donor lookup — admin-only free-text search across the donor master
list + online/offline transaction tables by name / email / phone /
address / bear name (columns discovered per table, deduped by email).
- Actions (danger zone) — heavy warnings, red buttons, and an
"are you sure" modal that spells out exactly what will happen:
• Wipe slate — delete ALL ticket + audit records in the active
event table (donor data untouched, irreversible).
• Switch event table — repoint the app at a different NocoDB
tickets/audit table to start a new event while keeping the old
one intact.
Backend:
- New /api/admin/{status,wipe,switch-table,donor-search}, all gated by
PORTAL_PASSWORD (POST-only so it never lands in a URL/log).
- NocoDBClient + AuditLogger: runtime-switchable tableId, count(),
deleteAll(), probeTable() (reachable + Id-PK check before switching).
- DonorService.search() with adaptive column discovery.
- Table switch persists across redeploys via a small state file on a
new /data volume (Dockerfile creates it owned by node so it's
writable); applied at startup in buildContext.
Also shipped equivalent CLI scripts: scripts/wipe-slate.sh and
scripts/switch-event.sh. Drawer: "Comp tickets" -> "Admin (crush33)".
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
60f0908299
commit
3a3119e324
15 changed files with 1042 additions and 172 deletions
|
|
@ -4,6 +4,7 @@ import { Mailer } from "./services/mailer.js";
|
|||
import { RedeemQueue } from "./services/redeemQueue.js";
|
||||
import { AuditLogger } from "./services/audit.js";
|
||||
import { DonorService } from "./services/donors.js";
|
||||
import { loadActiveTables } from "./services/state.js";
|
||||
|
||||
/** Shared services wired once at startup and hung off the Fastify instance. */
|
||||
export interface AppContext {
|
||||
|
|
@ -16,12 +17,23 @@ export interface AppContext {
|
|||
}
|
||||
|
||||
export function buildContext(config: Config): AppContext {
|
||||
const nocodb = new NocoDBClient(config);
|
||||
const audit = new AuditLogger(config);
|
||||
|
||||
// Apply a persisted "active event table" override (set from the admin area),
|
||||
// so switching the event survives redeploys without editing .env.
|
||||
const override = loadActiveTables(config.STATE_DIR);
|
||||
if (override) {
|
||||
nocodb.setTableId(override.ticketsTableId);
|
||||
audit.setTableId(override.auditTableId ?? null);
|
||||
}
|
||||
|
||||
return {
|
||||
config,
|
||||
nocodb: new NocoDBClient(config),
|
||||
nocodb,
|
||||
mailer: new Mailer(config),
|
||||
queue: new RedeemQueue(),
|
||||
audit: new AuditLogger(config),
|
||||
audit,
|
||||
donors: new DonorService(config),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue