diff --git a/frontend/app/exchange/page.tsx b/frontend/app/exchange/page.tsx index 8dd3eea..1d45b61 100644 --- a/frontend/app/exchange/page.tsx +++ b/frontend/app/exchange/page.tsx @@ -68,6 +68,7 @@ export default function ExchangePage() { // UI state const [error, setError] = useState(null); + const [existingTradeId, setExistingTradeId] = useState(null); const [isBooking, setIsBooking] = useState(false); // Compute dates @@ -266,7 +267,17 @@ export default function ExchangePage() { // Redirect to trades page after successful booking router.push("/trades"); } catch (err) { - setError(err instanceof Error ? err.message : "Failed to book trade"); + const errorMessage = err instanceof Error ? err.message : "Failed to book trade"; + setError(errorMessage); + + // Check if it's a "same day" error and extract trade ID + const tradeIdMatch = errorMessage.match(/Trade ID: (\d+)/); + if (tradeIdMatch) { + setExistingTradeId(parseInt(tradeIdMatch[1], 10)); + } else { + setExistingTradeId(null); + } + setIsBooking(false); } }; @@ -297,7 +308,18 @@ export default function ExchangePage() {

Exchange Bitcoin

Buy or sell Bitcoin with a 5% premium

- {error &&
{error}
} + {error && ( +
+ {error} + {existingTradeId && ( +
+ + View your existing trade → + +
+ )} +
+ )} {/* Price Display */}
@@ -998,6 +1020,18 @@ const styles: Record = { borderRadius: "6px", border: "1px solid rgba(251, 146, 60, 0.2)", }, + errorLink: { + marginTop: "0.75rem", + paddingTop: "0.75rem", + borderTop: "1px solid rgba(255, 255, 255, 0.1)", + }, + errorLinkAnchor: { + fontFamily: "'DM Sans', system-ui, sans-serif", + color: "#a78bfa", + textDecoration: "none", + fontWeight: 500, + fontSize: "0.9rem", + }, section: { marginBottom: "2rem", },