Skip to content

Commit

Permalink
fix: vote contract code
Browse files Browse the repository at this point in the history
  • Loading branch information
yongenaelf committed Jul 29, 2024
1 parent 136c02f commit ffba42f
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions docs/quick-start/developers/vote-contract/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -817,21 +817,17 @@ Let's write the Create Proposal function.
3. Replace the form variable with this code snippet:
```javascript title="src/CreateProposal.tsx"
```tsx title="src/CreateProposal.tsx"
//Step D - Configure Proposal Form
const form =
useForm <
z.infer <
typeof formSchema >>
{
resolver: zodResolver(formSchema),
defaultValues: {
address: currentWalletAddress,
title: "",
description: "",
voteThreshold: 0,
},
};
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
address: currentWalletAddress,
title: "",
description: "",
voteThreshold: 0,
},
});
```
:::tip
Expand Down Expand Up @@ -951,7 +947,7 @@ The `voteNo` function works similarly but sets the vote to `false`.
- Scroll down to the `Step G - Use Effect to Fetch Proposals` comment and replace the `useEffect` hook with this code snippet:
```javascript title="src/HomeDAO.tsx"
```tsx title="src/HomeDAO.tsx"
useEffect(() => {
// Step G - Use Effect to Fetch Proposals
const fetchProposals = async () => {
Expand All @@ -966,12 +962,15 @@ useEffect(() => {

if (!account) throw new Error("No account");

if (!DAOContract) return;

const proposalResponse =
(await DAOContract?.callViewMethod) <
IProposals >
("GetAllProposals", "");
await (DAOContract?.callViewMethod)<IProposals>(
"GetAllProposals",
""
);

setProposals(proposalResponse?.data);
setProposals(proposalResponse.data);
alert("Fetched Proposals");
} catch (error) {
console.error(error);
Expand Down

0 comments on commit ffba42f

Please sign in to comment.