import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
import { Link } from "react-router-dom";
import { Button, Row } from "antd";
import { Hands } from "./Icons";
import { useAppState } from "../../../overmind";
import { ApproveModal } from "./DaoModals/ApproveModal";
import { VoteModal } from "./DaoModals/VoteModal";
import { StakeModal } from "./DaoModals/StakeModal";
import { WithdrawForm } from "./DaoModals/WithdrawModal";
import { ExecuteModal } from "./DaoModals/ExecuteModal";
import { Avatar, Col } from "antd-latest";
import { useCachedUser } from "../../../hooks/useCached";
import { ContentImage } from "../../../Components/Image";
import { useGetAuthorizedActions } from "../Utils/Helpers";
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 = props.proposal;
    const proposer = proposal.proposer;
    const proposerObj = useCachedUser({ username: proposer });
    const proposal_type = "standart";
    const { status_tag, action_type, vote, timeData } = useGetAuthorizedActions({
        daoOwner, proposalId, proposal, currUser, proposal_type
    });
    return _jsx(Link, { to: `/dao/${props.daoOwner}/proposal/${proposal.id}`, children: _jsxs(Row, { className: props.wrapperClass, align: "middle", children: [_jsxs(Row, { align: "middle", className: "u-margin-left-large", children: [_jsxs("p", { className: "header-5 u-margin-right-large", children: ["#", proposal.id] }), _jsx("span", { className: "u-margin-right-large", children: _jsx(Hands, {}) }), _jsx("p", { className: "proposal-list-title-p", children: proposal.title })] }), _jsxs(Row, { align: "middle", className: "u-margin-right-large", children: [_jsx(Row, { className: "u-margin-right-large", children: _jsxs(Col, { className: "proposal-list-card-btm-user-details-left-ctn u-margin-right-large", children: [_jsxs(Row, { align: "bottom", children: [_jsxs(Link, { className: "proposal-list-props.proposal-avi-link u-margin-right-small", to: `/user/${proposal.proposer}`, children: [" ", _jsx(Avatar, { src: _jsx(ContentImage, { ...proposerObj }), className: "proposal-list-props.proposal-avi-cmpt" })] }), _jsxs("p", { className: "header-3", children: [proposal.proposer, " "] })] }), _jsxs("p", { className: "u-margin-right-large", children: [" ", timeData.time_end_date, " "] })] }) }), _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 }) }), (action_type == "View") && !props.embedded &&
                                    _jsx(Link, { to: `/dao/${daoOwner}/proposal/${proposal.id}`, children: _jsx(Button, { className: "u-dao-view-btn", children: action_type }) }), _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 == "GetWhitelisted") &&
                                    _jsx(Link, { to: `/dao/${daoOwner}/proposals`, children: _jsx(Button, { className: "u-dao-view-btn", children: "View" }) }), (action_type == "SeeOthers") &&
                                    _jsx(Link, { to: `/dao/${daoOwner}/proposals`, children: _jsx(Button, { className: "u-dao-view-btn", children: "View" }) }), 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] }) })] })] })] }) });
};
//# sourceMappingURL=ProposalRow.js.map