diff --git a/frontend/app/admin/trades/page.tsx b/frontend/app/admin/trades/page.tsx index 70212b0..57e31a4 100644 --- a/frontend/app/admin/trades/page.tsx +++ b/frontend/app/admin/trades/page.tsx @@ -34,8 +34,8 @@ export default function AdminTradesPage() { const [isLoadingTrades, setIsLoadingTrades] = useState(true); const [error, setError] = useState(null); - // Action state - const [actioningId, setActioningId] = useState(null); + // Action state - use Set to track multiple concurrent actions + const [actioningIds, setActioningIds] = useState>(new Set()); const [confirmAction, setConfirmAction] = useState<{ id: number; type: "complete" | "no_show" | "cancel"; @@ -100,7 +100,8 @@ export default function AdminTradesPage() { }, [user, isAuthorized, fetchUpcomingTrades, fetchPastTrades]); const handleAction = async (tradeId: number, action: "complete" | "no_show" | "cancel") => { - setActioningId(tradeId); + // Add this trade to the set of actioning trades + setActioningIds((prev) => new Set(prev).add(tradeId)); setError(null); try { @@ -120,7 +121,12 @@ export default function AdminTradesPage() { } catch (err) { setError(err instanceof Error ? err.message : `Failed to ${action} trade`); } finally { - setActioningId(null); + // Remove this trade from the set of actioning trades + setActioningIds((prev) => { + const next = new Set(prev); + next.delete(tradeId); + return next; + }); } }; @@ -284,14 +290,14 @@ export default function AdminTradesPage() { <>