import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useAppState } from "../../overmind";
import { Avatar, Col, Row } from "antd";
import { Link } from "react-router-dom";
import { ProgressBar } from "./Components/Icons";
import { useCachedDaoProposal, useCachedUser } from "../../hooks/useCached";
import { ProposalRow } from "./Components/ProposalRow";
import { useParams } from "react-router";
import { ContentImage } from "../../Components/Image";
import { getLocalTimeData } from "./Utils/Helpers";
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] : "";
    if (!(Number(proposal?.id) >= 0))
        return _jsx("div", { children: "Proposal was executed or does not exist." });
    return _jsxs(Col, { className: "view-proposal-wrapper", children: [_jsx(ProposalRow, { daoOwner: daoOwner, proposal: proposal, wrapperClass: "u-dao-row-wrapper", proposalId: proposal.id, embedded: true }), _jsx("p", { className: "u-dao-h-40px-r", children: proposal.title }), _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: "paragraph-2b", children: ["NO votes: ", (proposal.vote_no?.quantity), " "] }), _jsx(ProgressBar, { width: "642px", proposal: proposal }), _jsxs("p", { className: "view-proposal-time-p", 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(Row, { className: "view-proposal-user-details-wrapper", children: [_jsx(Link, { className: "proposal-list-proposal-avi-link", to: `/user/${proposal.proposer}`, children: _jsx(Avatar, { src: _jsx(ContentImage, { ...proposerObj }), className: "proposal-list-proposal-avi-cmpt" }) }), _jsxs(Row, { align: "middle", children: [_jsx("p", { className: "view-proposal-user-display-name-p", children: proposal.proposer }), _jsx("p", { className: "view-proposal-user-full-name-p", children: proposerObj.fullName })] })] })] });
};
export default ViewProposal;
//# sourceMappingURL=ViewProposal.js.map