import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
import { Button } from "antd";
import { CrossCircle } from "../../../../Components/Icons/CrossCircle";
import { Modal } from "antd-latest";
import { NewcoinRecept } from "../../../../Components/Recepts";
import { ProgressButton } from "../../../../Components/ProgressButton";
import { useActions } from "../../../../overmind";
import { useState } from "react";
export const WithdrawForm = ({ vote_id, quantity }) => {
    const withdrawStates = {
        disabled: 0,
        start: 1,
        reciept: 2,
        end: 3,
    };
    const actions = useActions();
    const [mode, setMode] = useState(withdrawStates.disabled);
    const [tx, setTx] = useState("");
    const withdraw = async () => {
        const res = await actions.newcoin.daoWithdrawVoteDeposit({ vote_id });
        const success = !!res.TxID_WithdrawVoteDeposit;
        if (success) {
            setTx(res.TxID_WithdrawVoteDeposit);
            setMode(withdrawStates.reciept);
        }
    };
    const endWithdrawing = async () => {
        setMode(withdrawStates.disabled);
        await actions.newcoin.getAccountBalance();
    };
    return (_jsxs("div", { style: { color: "white" }, children: [_jsxs(Button, { className: "power-up-btn", onClick: () => setMode(withdrawStates.start), children: ["Withdraw ", Math.round(quantity) || ""] }), "\u00A0", _jsxs(NewcoinRecept, { tx: tx, visible: mode == withdrawStates.reciept, onDone: endWithdrawing, children: [" ", _jsx("h1", { className: "view-proposal-vote-h1", children: "Nice! " }), _jsxs("p", { className: "view-proposal-vote-p", children: ["You've withdrawn your ", quantity, " vote deposit."] })] }), _jsxs(Modal, { closeIcon: _jsx(CrossCircle, {}), visible: mode == withdrawStates.start && quantity, onCancel: () => setMode(withdrawStates.disabled), className: "modal-ctn", footer: [], children: [_jsx("h2", { children: "This proposal has expired!" }), _jsx("p", { children: "Your vote is ready to be withdrawn" }), quantity && (_jsxs(ProgressButton, { actionName: "newcoin.daoWithdrawVoteDeposit", progressText: "Withdrawing...", onClick: withdraw, className: "confirm-btn", children: ["Withdraw ", Math.round(quantity)] })), _jsxs(Button, { onClick: () => setMode(withdrawStates.disabled), className: "cancel-btn", children: [" ", "Cancel"] }), _jsx("p", { children: "This is only on Testnet! Need help? Join our telegram group!" })] })] }));
};
//# sourceMappingURL=WithdrawModal.js.map