import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Avatar, Col } from "antd";
import { ContentImage } from "../../../../Components/Image";
import { Link } from "react-router-dom";
import { ProgressBar } from "../../Components/Icons";
import { ProposalFolder } from "../../Components/Links/ProposalFolder";
import { ProposalRow } from "../../Components/Previews/Standard/Row/ProposalRow";
import { VerifiedIcon } from "../../../../Components/Icons/VerifiedIcon";
import { getLocalTimeData } from "../../Utils/Helpers";
import { useAppState } from "../../../../overmind";
import { useCachedDaoProposal, useCachedUser } from "../../../../hooks/useCached";
import { useParams } from "react-router";
import { useVerified } from "../../../../hooks/useVerified";
export const ViewProposalPage = () => {
    const { daoOwner, id, proposal } = useParams();
    return _jsx(ViewProposal, { proposal: proposal, daoOwner: daoOwner, proposalId: id });
};
const ViewProposal = (props) => {
    const state = useAppState();
    const daoOwner = props.daoOwner || state.config.settings.newcoin.daoDomain;
    const proposalId = props.proposalId;
    const proposal = useCachedDaoProposal({ daoOwner, proposalId });
    const proposerObj = useCachedUser({ username: proposal.proposer });
    const timeData = getLocalTimeData(proposal);
    const proposalSummaryArr = proposal.summary?.split("#");
    const proposalSummary = proposalSummaryArr ? proposalSummaryArr[0] : "";
    const proposalType = proposalSummaryArr ? proposalSummaryArr[1] : "";
    const { verifiedUsers } = useVerified([proposal.proposer || ""]);
    const isUserVerified = verifiedUsers && proposal.proposer && verifiedUsers.includes(proposal.proposer);
    if (!(Number(proposal?.id) >= 0))
        return _jsx("div", { children: "Proposal was executed or does not exist." });
    return (_jsxs(Col, { children: [_jsx(ProposalRow, { daoOwner: daoOwner, proposal: proposal, wrapperClass: "u-dao-row-wrapper", proposalId: proposal.id, embedded: true, buttonType: false }), _jsxs("p", { className: "view-proposal-summary-p", children: [" ", proposalType && `Proposal Type: #${proposalType}`] }), _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: ["Ending: ", timeData.time_left_from_now, " "] }), _jsxs("p", { className: "view-proposal-summary-p", children: [" ", proposalSummary] }), _jsx("p", { className: "view-proposal-by-p", children: "Proposal by" }), _jsxs(Link, { to: `/user/${proposal.proposer}`, className: "view-proposal-avi-ctn", children: [_jsx(Avatar, { src: _jsx(ContentImage, { ...proposerObj }) }), _jsx("p", { className: "view-proposal-username", children: proposal.proposer }), isUserVerified && _jsx(VerifiedIcon, {})] }), _jsx("br", {}), _jsx("br", {}), _jsx(ProposalFolder, { proposal: proposal })] }));
};
export default ViewProposal;
//# sourceMappingURL=ViewProposal.js.map