From dbdcbe2b44533c7d876d0286bdbc20d8c7a632a5 Mon Sep 17 00:00:00 2001 From: codingsh Date: Sat, 18 Feb 2023 00:54:56 +0000 Subject: [PATCH] chore(epoch): update view epoch contributions --- src/pages/daos/[address].tsx | 92 ++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/src/pages/daos/[address].tsx b/src/pages/daos/[address].tsx index a71a859..e054c91 100644 --- a/src/pages/daos/[address].tsx +++ b/src/pages/daos/[address].tsx @@ -16,6 +16,9 @@ import Sector3DAOPriority from "../../../abis/Sector3DAOPriority.json"; import { ethers } from "ethers"; import Link from "next/link"; +import React, { useState } from "react"; + + const inter = Inter({ subsets: ["latin"] }); const { provider } = configureChains([goerli], [publicProvider()]); @@ -26,6 +29,8 @@ const client = createClient({ }); export default function DAO({ dao, priorities }: any) { + const [selectedPriorityContributions, setSelectedPriorityContributions] = useState([]); + console.log("DAO"); console.log("dao:", dao); @@ -62,7 +67,7 @@ export default function DAO({ dao, priorities }: any) {
{priorities.map((priority: any, index: number) => (
- Title: {priority.title} + Title: {priority.title}{index}
Reward token: {priority.rewardToken}
@@ -72,40 +77,20 @@ export default function DAO({ dao, priorities }: any) { Start date: {priority.startDate}
- + - {priority.epochContributions.length > 0 && ( -
-

- Contributions for epoch {priority.currentEpoch}: -

- - - - - - - - - - {contributions.map( - (contribution: any, index: number) => ( - - - - - ) - )} - - -
ContributorAmount
{contribution.contributor}{contribution.amount}
-
- )}
))}
+ {selectedPriorityContributions.length > 0 && } ); @@ -221,21 +206,21 @@ export async function getStaticProps(context: any) { const currentEpoch = Math.floor( Date.now() / (priorityData[3] * 24 * 60 * 60 * 1000) ); - const epochContributionsData = await readContract({ - address: priorityAddress, - abi: Sector3DAOPriority.abi, - functionName: "getEpochContributions", - args: [currentEpoch], - }); - - const epochContributions = epochContributionsData[1].map( - (amount: any, index: number) => { - const contributor = epochContributionsData[0][index]; - return { contributor, amount }; - } - ); - - console.log("epochContributions:", epochContributions); + // const epochContributionsData = await readContract({ + // address: priorityAddress, + // abi: Sector3DAOPriority.abi, + // functionName: "getEpochContributions", + // args: [currentEpoch], + // }); + + // const epochContributions = epochContributionsData[1].map( + // (amount: any, index: number) => { + // const contributor = epochContributionsData[0][index]; + // return { contributor, amount }; + // } + // ); + + // console.log("epochContributions:", epochContributions); } const dao = { @@ -250,4 +235,19 @@ export async function getStaticProps(context: any) { priorities: priorities, }, }; +} + + +export function Contributions({ contributions }: any) { + return ( +
+

Contributions:

+ {contributions.map((contribution: any, index: number) => ( +
+ Contributor: {contribution.contributor}
+ Amount: {contribution.amount}
+
+ ))} +
+ ) } \ No newline at end of file