import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Avatar, Button, Col, Row } from "antd";
import { ContentImage } from "../../../../../../Components/Image";
import { Hands, ProgressBar } from "../../../Icons";
import { Link } from "react-router-dom";
import { VerifiedIcon } from "../../../../../../Components/Icons/VerifiedIcon";
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 yesVotes = Number(props.proposal.vote_yes?.quantity?.split(" ")[0]);
    const noVotes = Number(props.proposal.vote_no?.quantity?.split(" ")[0]);
    const proposal = useCachedDaoWhitelistProposal({
        daoOwner,
        proposalId: props?.proposal?.id,
    });
    const proposer = proposal.proposer;
    const proposerObj = useCachedUser({ username: proposer });
    const newMember = useCachedUser({ username: proposal.user });
    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}/member-proposal/${proposalId}`, children: _jsxs(Row, { className: "wlst-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", { children: ["#", proposal.id] }) })] }), _jsxs(Col, { children: [_jsxs(Link, { to: `/user/${proposal.user}`, className: "wlst-member-details", children: [_jsx(Avatar, { src: _jsx(ContentImage, { ...newMember }), className: "wlst-member-avi" }), _jsxs("p", { className: "wlst-member-username", children: [" ", proposal.user] })] }), _jsxs(Row, { align: "middle", justify: "space-between", className: "view-proposal-votes-ctn", children: [_jsxs("p", { className: "paragraph-2b", children: [" ", yesVotes, " yes votes "] }), _jsxs("p", { className: "paragraph-2b", children: [" ", noVotes, " no votes "] })] }), _jsx(ProgressBar, { width: "750px", 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: _jsx(Link, { to: `/dao/${daoOwner}/proposal/${proposal.id}`, children: _jsx(Button, { className: "u-dao-view-btn", children: "View" }) }) }), _jsxs(Row, { align: "middle", className: "wlst-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(VerifiedIcon, {})] })] })] }) }));
};
//# sourceMappingURL=WhitelistProposalRow.js.map