import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Avatar, Col, Row } from "antd";
import { ContentImage } from "../../../../Components/Image";
import { Link } from "react-router-dom";
import { ProgressBar } from "../../Components/Icons";
import { UserStake } from "../../../../Components/UserWidget";
import { ViewWhitelistProposalPageRow } from "../../Components/Previews/Whitelist/ViewWhitelistProposalPageRow/ViewWhitelistProposalPageRow";
import { getLocalTimeData } from "../../Utils/Helpers";
import { useAppState } from "../../../../overmind";
import { useCachedDaoWhitelistProposal, useCachedPool, useCachedUser } from "../../../../hooks/useCached";
import { useParams } from "react-router";
export const ViewWhitelistProposalPage = () => {
    const { daoOwner, id, proposal } = useParams();
    return _jsx(ViewWhitelistProposal, { proposal: proposal, daoOwner: daoOwner, proposalId: id });
};
const ViewWhitelistProposal = (props) => {
    const state = useAppState();
    const daoOwner = props.daoOwner || state.config.settings.newcoin.daoDomain;
    const proposalId = props.proposalId;
    const proposal = useCachedDaoWhitelistProposal({ daoOwner, proposalId });
    const proposerObj = useCachedUser({ username: proposal.proposer });
    const timeData = getLocalTimeData(proposal);
    const daoOwnerObj = useCachedUser({ username: daoOwner });
    const pool = useCachedPool({ owner: daoOwner });
    if (!(Number(proposal?.id) >= 0))
        return _jsx("div", { children: "Proposal was executed or does not exist." });
    const yesVotes = Number(proposal.vote_yes?.quantity?.split(" ")[0]);
    const noVotes = Number(proposal.vote_no?.quantity?.split(" ")[0]);
    const totalVotes = yesVotes + noVotes;
    return (_jsxs(Col, { className: "view-proposal-wrapper", children: [_jsx(ViewWhitelistProposalPageRow, { daoOwner: daoOwner, proposalId: proposalId, proposal: proposal, wrapperClass: "u-dao-row-wrapper u-dao-margin-btm-40px", embedded: true, buttonType: false }), _jsx("p", { className: "view-proposal-type-p", children: " #new member" }), _jsx(Row, { align: "middle", children: _jsxs("div", { className: "view-proposal-row-dao-details", children: ["Posted by", _jsxs(Link, { to: `/user/${proposal.proposer}`, className: "view-proposal-avi-ctn", children: [_jsx(Avatar, { src: _jsx(ContentImage, { ...proposerObj }) }), _jsx("p", { className: "view-proposal-row-username", children: proposal.proposer })] }), "in the", _jsxs(Link, { to: `/user/${proposal.proposer}`, className: "view-proposal-avi-ctn", children: [_jsx(Avatar, { src: _jsx(ContentImage, { ...daoOwnerObj }) }), _jsx("p", { className: "view-proposal-row-username", children: daoOwnerObj.username })] }), "DAO", _jsx(UserStake, { buttonText: `Get $${pool.code}`, user: { username: daoOwner }, hideButton: false })] }) }), _jsxs("p", { className: "paragraph-2b", children: [timeData.time_left_seconds > 0 ? "Ending" : "Ended", " ", timeData.time_left_from_now, " "] }), _jsxs("p", { className: "paragraph-1b u-margin-top-large", children: [totalVotes, " votes "] }), _jsx(ProgressBar, { width: "100%", proposal: proposal }), _jsxs(Row, { align: "middle", justify: "space-between", className: "view-proposal-votes-ctn", children: [_jsxs("p", { className: "u-margin-bottom-15 paragraph-2b", children: [" ", yesVotes, " yes votes "] }), _jsxs("p", { className: "u-margin-bottom-15 paragraph-2b", children: [" ", noVotes, " no votes "] })] })] }));
};
export default ViewWhitelistProposal;
//# sourceMappingURL=ViewWhitelistProposal.js.map