diff --git a/client/src/App.jsx b/client/src/App.jsx
index 0af0a1f..31dac14 100644
--- a/client/src/App.jsx
+++ b/client/src/App.jsx
@@ -53,8 +53,9 @@ function App() {
setReputation,
account,
chainId,
+ posts,
}), [
- provider, DAO, work1, onboarding, reputation, setReputation, account, chainId]);
+ provider, DAO, work1, onboarding, reputation, setReputation, account, chainId, posts]);
// In this effect, we initialize everything and add contract event listeners.
useEffect(() => {
diff --git a/client/src/components/Proposals.jsx b/client/src/components/Proposals.jsx
index cf9d301..ceea367 100644
--- a/client/src/components/Proposals.jsx
+++ b/client/src/components/Proposals.jsx
@@ -10,6 +10,8 @@ import Web3Context from '../contexts/Web3Context';
import ProposalsArtifact from '../assets/Proposals.json';
import { getContractAddressByChainId } from '../utils/contract-config';
import AddPostModal from './posts/AddPostModal';
+import ViewPostModal from './posts/ViewPostModal';
+import Post from '../utils/Post';
const getProposalStatus = (proposal) => {
switch (Number(proposal.stage)) {
@@ -25,11 +27,13 @@ const getProposalStatus = (proposal) => {
function Proposals() {
const {
- provider, chainId, account, reputation,
+ provider, chainId, account, reputation, posts,
} = useContext(Web3Context);
const [proposals, dispatchProposal] = useList();
const proposalsContract = useRef();
const [showAddProposal, setShowAddProposal] = useState(false);
+ const [showViewProposal, setShowViewProposal] = useState(false);
+ const [viewPost, setViewPost] = useState(false);
const [durations, setDurations] = useState([]);
const fetchProposal = useCallback(async (proposalIndex) => {
@@ -91,6 +95,13 @@ function Proposals() {
setShowAddProposal(true);
};
+ const handleShowViewProposal = useCallback(async (proposal) => {
+ const { postIndex } = proposal;
+ const post = await Post.read(posts[postIndex].contentId);
+ setViewPost(post);
+ setShowViewProposal(true);
+ }, [posts, setViewPost, setShowViewProposal]);
+
const onSubmitProposal = useCallback(async (post) => {
// TODO: Make referenda durations configurable
await proposalsContract.current.methods.propose(
@@ -158,15 +169,10 @@ function Proposals() {
onSubmit={onSubmitProposal}
/>
-