diff options
| author | Greg Stupp | 2026-09-24 22:00:58 +0000 |
|---|---|---|
| committer | Greg Stupp | 2026-09-24 22:00:58 +0000 |
| commit | a5e1f9d5fe8b1d4e66c240a69eff34a8d0e8dff7 (patch) | |
| tree | 61d38c3796c1e758a344edec7ce52bcb6ee64f36 /jb-ui/src/pages | |
| parent | 6249139ee928b954e74ac42df81211f1a8094b53 (diff) | |
| parent | be986ab84f7b12c211f7675071d4deae1bf2bd03 (diff) | |
| download | amt-jb-a5e1f9d5fe8b1d4e66c240a69eff34a8d0e8dff7.tar.gz amt-jb-a5e1f9d5fe8b1d4e66c240a69eff34a8d0e8dff7.zip | |
Merges pull request #5
wallet views
Diffstat (limited to 'jb-ui/src/pages')
| -rw-r--r-- | jb-ui/src/pages/CashoutConfirmation.tsx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/jb-ui/src/pages/CashoutConfirmation.tsx b/jb-ui/src/pages/CashoutConfirmation.tsx new file mode 100644 index 0000000..6964672 --- /dev/null +++ b/jb-ui/src/pages/CashoutConfirmation.tsx @@ -0,0 +1,41 @@ +import { useEffect, useRef, useState } from "react"; + +type ConfirmationState = "working" | "confirmed" | "failed" | "missing"; + +const CashoutConfirmation = function () { + const started = useRef(false); + const [state, setState] = useState<ConfirmationState>("working"); + + useEffect(() => { + if (started.current) return; + started.current = true; + + const params = new URLSearchParams(window.location.search); + const token = params.get("token"); + if (!token) { + setState("missing"); + return; + } + + window.history.replaceState({}, "", window.location.pathname); + + void fetch("/wallet/cashout/confirm/", { + method: "POST", + credentials: "include", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ token }), + }) + .then((response) => { + if (!response.ok) throw new Error("Cashout confirmation failed"); + setState("confirmed"); + }) + .catch(() => setState("failed")); + }, []); + + if (state === "missing") return <p>This cashout link is missing its token.</p>; + if (state === "failed") return <p>This cashout link is invalid or has expired.</p>; + if (state === "confirmed") return <p>Your cashout has been confirmed.</p>; + return <p>Confirming your cashout…</p>; +}; + +export default CashoutConfirmation; |
