import { useEffect, useRef, useState } from "react"; type ConfirmationState = "working" | "confirmed" | "failed" | "missing"; const CashoutConfirmation = function () { const started = useRef(false); const [state, setState] = useState("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

This cashout link is missing its token.

; if (state === "failed") return

This cashout link is invalid or has expired.

; if (state === "confirmed") return

Your cashout has been confirmed.

; return

Confirming your cashout…

; }; export default CashoutConfirmation;