import { Header, Loader } from "@/components"; import { collectBountyFn } from "@/libs/contractFunctionCall"; import { readAnswerTableFunc, readQuestionTableFunc, } from "@/libs/TablelandFnCall"; import { ethers } from "ethers"; import Link from "next/link"; import React, { useEffect, useState } from "react"; const Dashboard = () => { const [questionData, setQuestionData] = useState([]); const [answerData, setAnswerData] = useState([]); const [loader, setLoader] = useState(true); const getQuestions = async () => { const provider = new ethers.providers.Web3Provider(window.ethereum); await provider.send("eth_requestAccounts", []); const signer = await provider.getSigner(); const account = await signer.getAddress(); const result = await readQuestionTableFunc(); setQuestionData(result.filter((item) => item.address === account)); setLoader(false); }; const getAnswer = async () => { const provider = new ethers.providers.Web3Provider(window.ethereum); await provider.send("eth_requestAccounts", []); const signer = await provider.getSigner(); const account = await signer.getAddress(); const result = await readAnswerTableFunc(); console.log(result) setAnswerData(result.filter((item) => item.address === account)); setLoader(false); }; const collectBountyPool = async (questionId) => { const provider = new ethers.providers.Web3Provider(window.ethereum); await provider.send("eth_requestAccounts", []); const signer = await provider.getSigner(); const res = await collectBountyFn(signer, questionId); if (res) { document.getElementById("my_modal_1").showModal(); } }; useEffect(() => { getAnswer(); getQuestions(); }, []); return (

Bounty already claimed!

Bounty has already been distributed.

{/* if there is a button in form, it will close the modal */}

Your Dashboard

{loader ? ( ) : (
{questionData?.map(({ question, question_id }, index) => { return ( {index + 1}. {question} ); })}
{answerData?.map(({ answer, question_Id }, index) => { return (
Ans {index + 1}.{" "}
); })}
)}
); }; export default Dashboard;