From 1ad9ceaa85b3e52dc40dd3f77b936a21affccbca Mon Sep 17 00:00:00 2001 From: Ladd Hoffman Date: Fri, 29 Mar 2024 18:50:35 -0500 Subject: [PATCH] Add duration options for new proposals --- client/src/components/Proposals.jsx | 38 +++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/client/src/components/Proposals.jsx b/client/src/components/Proposals.jsx index b6e1092..cf9d301 100644 --- a/client/src/components/Proposals.jsx +++ b/client/src/components/Proposals.jsx @@ -30,6 +30,7 @@ function Proposals() { const [proposals, dispatchProposal] = useList(); const proposalsContract = useRef(); const [showAddProposal, setShowAddProposal] = useState(false); + const [durations, setDurations] = useState([]); const fetchProposal = useCallback(async (proposalIndex) => { const proposal = await proposalsContract.current.methods.proposals(proposalIndex).call(); @@ -85,16 +86,24 @@ function Proposals() { }; }, [provider, chainId, proposalsContract, fetchProposals, fetchProposal]); - const handleShowAddProposal = () => setShowAddProposal(true); + const handleShowAddProposal = (duration0, duration1, duration2) => { + setDurations([duration0, duration1, duration2]); + setShowAddProposal(true); + }; const onSubmitProposal = useCallback(async (post) => { // TODO: Make referenda durations configurable - await proposalsContract.current.methods.propose(post.hash, 20, 40, 60).send({ + await proposalsContract.current.methods.propose( + post.hash, + durations[0], + durations[1], + durations[2], + ).send({ from: account, gas: 1000000, value: 10000, }); - }, [account, proposalsContract]); + }, [account, proposalsContract, durations]); const handleAttest = useCallback(async (proposalIndex) => { await proposalsContract.current.methods.attest(proposalIndex, reputation).send({ @@ -142,10 +151,29 @@ function Proposals() { }; return ( <> - + + + +

Proposals

- + + + + +