lots of stuff
This commit is contained in:
parent
f946fbf7b8
commit
4be45f8f7c
9 changed files with 513 additions and 236 deletions
|
|
@ -35,9 +35,9 @@ export default function AdminTradesPage() {
|
|||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
// Action state - use Set to track multiple concurrent actions
|
||||
const [actioningIds, setActioningIds] = useState<Set<number>>(new Set());
|
||||
const [actioningIds, setActioningIds] = useState<Set<string>>(new Set());
|
||||
const [confirmAction, setConfirmAction] = useState<{
|
||||
id: number;
|
||||
id: string;
|
||||
type: "complete" | "no_show" | "cancel";
|
||||
} | null>(null);
|
||||
|
||||
|
|
@ -99,16 +99,16 @@ export default function AdminTradesPage() {
|
|||
}
|
||||
}, [user, isAuthorized, fetchUpcomingTrades, fetchPastTrades]);
|
||||
|
||||
const handleAction = async (tradeId: number, action: "complete" | "no_show" | "cancel") => {
|
||||
const handleAction = async (publicId: string, action: "complete" | "no_show" | "cancel") => {
|
||||
// Add this trade to the set of actioning trades
|
||||
setActioningIds((prev) => new Set(prev).add(tradeId));
|
||||
setActioningIds((prev) => new Set(prev).add(publicId));
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const endpoint =
|
||||
action === "no_show"
|
||||
? `/api/admin/trades/${tradeId}/no-show`
|
||||
: `/api/admin/trades/${tradeId}/${action}`;
|
||||
? `/api/admin/trades/${publicId}/no-show`
|
||||
: `/api/admin/trades/${publicId}/${action}`;
|
||||
|
||||
await api.post<AdminExchangeResponse>(endpoint, {});
|
||||
// Refetch trades - errors from fetch are informational, not critical
|
||||
|
|
@ -124,7 +124,7 @@ export default function AdminTradesPage() {
|
|||
// Remove this trade from the set of actioning trades
|
||||
setActioningIds((prev) => {
|
||||
const next = new Set(prev);
|
||||
next.delete(tradeId);
|
||||
next.delete(publicId);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
|
@ -298,18 +298,18 @@ export default function AdminTradesPage() {
|
|||
|
||||
{/* Actions */}
|
||||
<div style={styles.buttonGroup}>
|
||||
{confirmAction?.id === trade.id ? (
|
||||
{confirmAction?.id === trade.public_id ? (
|
||||
<>
|
||||
<button
|
||||
onClick={() => handleAction(trade.id, confirmAction.type)}
|
||||
disabled={actioningIds.has(trade.id)}
|
||||
onClick={() => handleAction(trade.public_id, confirmAction.type)}
|
||||
disabled={actioningIds.has(trade.public_id)}
|
||||
style={
|
||||
confirmAction.type === "cancel"
|
||||
? styles.dangerButton
|
||||
: styles.successButton
|
||||
}
|
||||
>
|
||||
{actioningIds.has(trade.id) ? "..." : "Confirm"}
|
||||
{actioningIds.has(trade.public_id) ? "..." : "Confirm"}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setConfirmAction(null)}
|
||||
|
|
@ -325,7 +325,7 @@ export default function AdminTradesPage() {
|
|||
<button
|
||||
onClick={() =>
|
||||
setConfirmAction({
|
||||
id: trade.id,
|
||||
id: trade.public_id,
|
||||
type: "complete",
|
||||
})
|
||||
}
|
||||
|
|
@ -336,7 +336,7 @@ export default function AdminTradesPage() {
|
|||
<button
|
||||
onClick={() =>
|
||||
setConfirmAction({
|
||||
id: trade.id,
|
||||
id: trade.public_id,
|
||||
type: "no_show",
|
||||
})
|
||||
}
|
||||
|
|
@ -350,7 +350,7 @@ export default function AdminTradesPage() {
|
|||
<button
|
||||
onClick={() =>
|
||||
setConfirmAction({
|
||||
id: trade.id,
|
||||
id: trade.public_id,
|
||||
type: "cancel",
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue