Admin: per-event registrations view, contact deletion, collapsible interface logs
- Registrations: event selector dropdown (default = active event), event name shown prominently in header with active badge, 'Delete all contacts for this event' action (deletes the contacts registered for the selected event) - Contacts: per-row Delete button (with confirm; cascades to registrations) - Interfaces: Sessionize + Pretix 'Recent runs' tables now in per-interface collapsibles, collapsed by default - api: deleteContact + deleteContacts helpers
This commit is contained in:
1 parent
c7d095aff7
commit
98f65e8665
4 files changed
+197
-66
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { adjustPoints, getAllContacts, updateContact, upsertContact } from '../lib/api';
|
||||
import { adjustPoints, deleteContact, getAllContacts, updateContact, upsertContact } from '../lib/api';
|
||||
import type { Contact } from '../lib/types';
|
||||
import { useToast } from '../context/ToastContext';
|
||||
import { Avatar, Empty, Modal, Spinner, Toggle } from '../components/ui';
|
||||
@@ -13,6 +13,7 @@ export function Contacts() {
|
||||
const [editing, setEditing] = useState<Contact | null>(null);
|
||||
const [creating, setCreating] = useState(false);
|
||||
const [pointsFor, setPointsFor] = useState<Contact | null>(null);
|
||||
const [deleting, setDeleting] = useState<string | null>(null);
|
||||
|
||||
async function load() {
|
||||
try {
|
||||
@@ -22,6 +23,20 @@ export function Contacts() {
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(c: Contact) {
|
||||
if (!confirm(`Delete ${c.full_name} (${c.email})? This also removes their registrations.`)) return;
|
||||
setDeleting(c.email);
|
||||
try {
|
||||
await deleteContact(c.email);
|
||||
await load();
|
||||
push('success', `Deleted ${c.full_name}`);
|
||||
} catch (e) {
|
||||
push('error', e instanceof Error ? e.message : 'Delete failed');
|
||||
} finally {
|
||||
setDeleting(null);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
load();
|
||||
}, []);
|
||||
@@ -120,6 +135,13 @@ export function Contacts() {
|
||||
<button className="btn small" onClick={() => setPointsFor(c)}>
|
||||
Points
|
||||
</button>
|
||||
<button
|
||||
className="btn small danger"
|
||||
disabled={deleting === c.email}
|
||||
onClick={() => remove(c)}
|
||||
>
|
||||
{deleting === c.email ? 'Deleting…' : 'Delete'}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Reference in new issue
Block a user