import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
import { ApproveModal } from "./Modals/ApproveModal";
import { Avatar, Button, Col, Row } from "antd";
import { ContentImage } from "../../../Components/Image";
import { ExecuteModal } from "./Modals/ExecuteModal";
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 { useCachedDaoWhitelistProposal, useCachedUser } from "../../../hooks/useCached";
import { useGetAuthorizedActions } from "../Utils/Helpers";
import { useVerified } from "../../../hooks/useVerified";
export const WhitelistProposalRow = (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 = useCachedDaoWhitelistProposal({
        daoOwner,
        proposalId: props?.proposal?.id,
    });
    const proposer = proposal.proposer;
    const proposerObj = useCachedUser({ username: proposer });
    const proposal_type = "whitelist";
    const { status_tag, action_type, vote, timeData } = useGetAuthorizedActions({
        daoOwner,
        proposalId,
        proposal,
        currUser,
        proposal_type,
    });
    const { verifiedUsers } = useVerified([proposer || ""]);
    const isUserVerified = verifiedUsers && proposer && verifiedUsers.includes(proposer);
    return (_jsx(Link, { to: `/dao/${props.daoOwner}/whitelist-proposal/${proposalId}`, 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: ["#", props.proposalId] }), _jsx(Col, { className: "proposal-list-card-btm-user-details-left-ctn u-margin-right-large", children: _jsxs(Link, { className: "proposal-list-props.proposal-avi-link", to: `/user/${proposal.user}`, children: [" ", _jsx(Avatar, { src: _jsx(ContentImage, { ...proposerObj }), className: "proposal-list-props.proposal-avi-cmpt" })] }) }), _jsxs(Col, { children: [_jsxs("p", { className: "header-3 u-margin-right-large", children: [" ", proposal.user] }), _jsxs("p", { className: "header-5 u-margin-right-large", style: { display: "inline-flex", justifyContent: "center" }, children: ["proposal by: ", proposal.proposer, isUserVerified ? (_jsx("span", { className: "u-margin-left-medium", children: _jsx(VerifiedIcon, {}) })) : (false)] })] })] }), _jsxs(Row, { align: "middle", className: "u-margin-right-large", children: [_jsx(Col, { className: "proposal-list-timestamp-ctn u-margin-right-large", children: _jsxs("p", { className: "u-margin-right-large", children: [" ", timeData.time_end_date, " "] }) }), 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 }) }), 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: "whitelist", dao_owner: daoOwner, proposal_id: proposal.id })), _jsx(VoteModal, { proposal_type: "whitelist", daoOwner: daoOwner, proposal: proposal, proposalId: proposal.id, visible: action_type == "Vote" }), 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: "whitelist", dao_id: proposal.dao_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] }) })), ["Withdraw", "Execute"].includes(action_type) && vote?.id && (_jsx(WithdrawForm, { vote_id: vote?.id, quantity: vote?.quantity?.quantity })), " "] }))] })] }) }));
};
//# sourceMappingURL=WhitelistProposalRow.js.map