import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { ApproveModal } from "../../../Modals/ApproveModal";
import { Avatar, Col } from "antd-latest";
import { Button, Row } from "antd";
import { ContentImage } from "../../../../../../Components/Image";
import { ExecuteModal } from "../../../Modals/ExecuteModal";
import { Hands, ProgressBar } from "../../../Icons";
import { Link } from "react-router-dom";
import { StakeModal } from "../../../Modals/StakeModal";
import { VerifiedIcon } from "../../../../../../Components/Icons/VerifiedIcon";
import { VoteModal } from "../../../Modals/VoteModal";
import { WithdrawForm } from "../../../Modals/WithdrawModal";
import { useAppState } from "../../../../../../overmind";
import { useCachedDaoProposal, useCachedUser } from "../../../../../../hooks/useCached";
import { useGetAuthorizedActions } from "../../../../Utils/Helpers";
import { useVerified } from "../../../../../../hooks/useVerified";
export const ProposalRow = (props) => {
    const state = useAppState();
    const currUser = state.api.auth.user?.username || "";
    const daoOwner = props.daoOwner || state.config.settings.newcoin.daoDomain;
    const proposalId = props.proposal.id;
    const proposal = useCachedDaoProposal({
        daoOwner,
        proposalId: props?.proposal?.id,
    });
    const proposer = proposal.proposer;
    const proposerObj = useCachedUser({ username: proposer });
    const proposal_type = "standart";
    const { status_tag, action_type, vote, timeData } = useGetAuthorizedActions({
        daoOwner,
        proposalId,
        currUser,
        proposal_type,
        proposal,
    });
    const { verifiedUsers } = useVerified([proposer || ""]);
    const isUserVerified = verifiedUsers && proposer && verifiedUsers.includes(proposer);
    return (_jsx(Link, { to: `/dao/${props.daoOwner}/proposal/${proposal.id}`, children: _jsxs(Row, { className: "std-row-wrapper", justify: "space-between", children: [_jsxs(Row, { align: "top", className: "u-dao-gap-40", children: [_jsxs(Col, { children: [_jsx(Row, { align: "top", justify: "center", children: _jsx("span", { children: _jsx(Hands, { width: "50", height: "50" }) }) }), _jsx(Row, { align: "top", justify: "center", children: _jsxs("p", { className: "id-p", children: ["#", proposal.id] }) })] }), _jsxs(Col, { children: [_jsx("p", { className: "title-p", children: proposal.title }), _jsxs("p", { className: "paragraph-2b", children: ["YES votes: ", proposal.vote_yes?.quantity] }), _jsxs("p", { className: "u-margin-bottom-15 paragraph-2b", children: ["NO votes: ", proposal.vote_no?.quantity, " "] }), _jsx(ProgressBar, { width: "642px", proposal: proposal }), _jsxs("p", { className: "paragraph-2b", children: [timeData.time_left_seconds > 0 ? "Ending" : "Ended", " ", timeData.time_left_from_now, " "] })] })] }), _jsxs(Col, { children: [_jsx(Row, { justify: "end", children: props.buttonType ? (_jsx(Link, { to: `/dao/${daoOwner}/proposal/${proposal.id}`, children: _jsx(Button, { className: "u-dao-view-btn", children: "View" }) })) : (_jsxs(Row, { className: "proposal-list-btns-ctn", children: [_jsx(Button, { className: `u-dao-proposal-${status_tag}-tag-status-btn u-margin-right-medium`, children: _jsx("span", { children: status_tag }) }), ["View", "GetWhitelisted", "SeeOthers"].includes(action_type) && !props.embedded && (_jsx(Link, { to: `/dao/${daoOwner}/proposal/${proposal.id}`, children: _jsx(Button, { className: "u-dao-view-btn", children: "View" }) })), _jsx(StakeModal, { visible: action_type == "Stake", daoOwner: daoOwner }), action_type == "Approve" && (_jsx(ApproveModal, { proposal_type: "standart", dao_owner: daoOwner, proposal_id: proposal.id })), _jsx(VoteModal, { proposal_type: "standart", daoOwner: daoOwner, proposal: proposal, proposalId: proposal.id, visible: action_type == "Vote" }), ["Withdraw", "Execute"].includes(action_type) && vote?.id && (_jsx(WithdrawForm, { vote_id: vote?.id, quantity: vote?.quantity?.quantity })), action_type == "Execute" && (_jsx(ExecuteModal, { dao_owner: daoOwner, proposal_type: "standart", dao_id: proposal.id, proposal_id: proposal.id, proposal_author: proposal.proposer })), action_type == "Voted" && (_jsx(Button, { className: "u-dao-view-btn", children: _jsxs("small", { children: ["Voted ", vote?.quantity?.quantity] }) }))] })) }), _jsxs(Row, { align: "middle", className: "std-row-usr-details", children: [_jsx(Link, { className: "", to: `/user/${proposal.proposer}`, children: _jsx(Avatar, { src: _jsx(ContentImage, { ...proposerObj }) }) }), _jsxs("p", { className: "header-3", children: [proposal.proposer, " "] }), isUserVerified && (_jsx("span", { children: _jsx(VerifiedIcon, {}) }))] })] })] }) }));
};
//# sourceMappingURL=ProposalRow.js.map