import { Button, DatePicker, Form, Input, Row, Select, Tooltip } from "antd-latest"; import { ContentLayout } from "../../../../Components/ContentLayout"; import { DownArrow } from "../../Components/Icons"; import { GetWhitelistedModal } from "../../Components/Modals/GetWhitelistedModal"; import { NewcoinRecept } from "../../../../Components/Recepts"; import { ProgressButton } from "../../../../Components/ProgressButton"; import { RowCheckbox } from "../../../../Components/RowCheckbox"; import { SearchWidget } from "../../../Search/SearchWidget"; import { useActions, useAppState } from "../../../../overmind"; import { useCachedDaoWhitelist } from "../../../../hooks/useCached"; import { useForm } from "antd-latest/lib/form/Form"; import { useParams } from "react-router-dom"; import { useState } from "react"; import moment from "moment"; export const NewProposal = () => { const state = useAppState(); const [form] = useForm(); const actions = useActions(); const proposalType = Form.useWatch("proposal_type", form); const { daoOwner: _daoOwner } = useParams<{ daoOwner }>(); const daoOwner = _daoOwner || state.config.settings.newcoin.daoDomain; const ownDao = state.api.auth.user?.username === daoOwner; const [proposalCreated, setProposalCreated] = useState(false); const [customTime, setCustomTime] = useState(false); const [voteEnd, setVoteEnd] = useState({}); const [tx, setTx] = useState(""); const [autoApprove, setAutoApprove] = useState({ consent: false, id: "" }); const autoApproveConsentInfo = "Since you are the DAO owner, you can choose to approve this proposal on creation. If you'd rather approve this proposal later, leave the box unchecked."; const isWhitelisted = ownDao || useCachedDaoWhitelist(daoOwner).rows?.some((user) => user == state.api.auth.user?.username); const proposalCreate = async (val: { custom_vote_end; custom_vote_start; title; summary; proposal_type; auto_approve; url; whitelist_selection; }) => { const voteStartTime = val.custom_vote_start ? val.custom_vote_start : moment().add("5", "minutes").utc().format("YYYY-MM-DDTHH:mm:ss"); const voteEndTime = val.custom_vote_end ? val.custom_vote_end : voteEnd ? voteEnd.time : moment().add("6", "minutes"); const proposalAction = proposalType == "whitelist" ? "daoCreateWhitelistProposal" : "daoCreateProposal"; const types = { whitelist: { user: val.whitelist_selection, }, standard: { summary: val.summary + "#" + proposalType, url: val.url || "blank", title: val.title, }, }; const payLoad = proposalType == "whitelist" ? types.whitelist : types.standard; const res = await actions.newcoin[proposalAction]({ ...payLoad, vote_start: voteStartTime, vote_end: voteEndTime, dao_owner: daoOwner, user: val.whitelist_selection, }); const success = !!res.TxID_createDaoProposal; if (success) { setTx(res["TxID_createDaoProposal"]); setProposalCreated(true); if (val.auto_approve) setAutoApprove({ consent: true, id: res.proposal_id }); } }; const createApprove = async () => { proposalType == "whitelist" ? await actions.newcoin.daoApproveWhitelistProposal({ dao_owner: daoOwner, proposal_id: autoApprove.id }) : await actions.newcoin.daoApproveProposal({ dao_owner: daoOwner, proposal_id: autoApprove.id, }); actions.routing.historyPush({ location: `/dao/${daoOwner}/proposals` }); }; return (
{!isWhitelisted && }

{proposalType == "whitelist" ? "new member" : "new proposal"}

{!(proposalType == "whitelist") && ( )} {proposalType == "whitelist" && ( )}

How long is your proposal live for?

{customTime && ( )} {customTime && ( )} {!(proposalType == "whitelist") && ( )} {!(proposalType == "whitelist") && ( )}

I am fostering community health

{ownDao && (

I consent to auto approval of my proposal

)}
{" "} Share Proposal actions.routing.historyPush({ location: `/dao/${daoOwner}/proposals` }) : createApprove } >

Congratulations!

You Created a proposal and shared it to the {daoOwner} DAO!

); }; export default NewProposal;