From 350e1b683d15e89ad1cb4a5198d9002fe38c3aa6 Mon Sep 17 00:00:00 2001 From: Me1e Date: Wed, 2 Aug 2023 00:09:29 +0900 Subject: [PATCH] =?UTF-8?q?feat(detail):=20loading=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/nextjs/components/Writer.tsx | 43 ++++++++++++++------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/packages/nextjs/components/Writer.tsx b/packages/nextjs/components/Writer.tsx index 32cdb7c..f9c7a35 100644 --- a/packages/nextjs/components/Writer.tsx +++ b/packages/nextjs/components/Writer.tsx @@ -1,26 +1,9 @@ +import { useEffect } from "react"; import styled from "@emotion/styled"; -import { Button } from "@mui/material"; -import { useAccount } from "wagmi"; import { useScaffoldContractWrite } from "~~/hooks/scaffold-eth"; -const FactButton = styled.div` - width: 126px; - height: 36px; - border-radius: 30px; - background: #000; - color: #fff; - display: flex; - align-items: center; - justify-content: center; - font-size: 12px; - font-weight: 600; - cursor: pointer; -`; - -// export default function Writer({ cid }) { -export default function Writer({ contractName, functionName, args, text }) { - // const { address, isConnecting, isDisconnected } = useAccount(); - const { writeAsync, isLoading, isMining } = useScaffoldContractWrite({ +export default function Writer({ contractName, functionName, args, text }: any) { + const { writeAsync, isSuccess } = useScaffoldContractWrite({ contractName: contractName, functionName: functionName, args: [...args], @@ -38,5 +21,25 @@ export default function Writer({ contractName, functionName, args, text }) { await writeAsync(); } + useEffect(() => { + if (isSuccess === true) { + alert("Fact Checked! It will be reflected in a moment."); + } + }, [isSuccess]); + return {text}; } + +const FactButton = styled.div` + width: 126px; + height: 36px; + border-radius: 30px; + background: #000; + color: #fff; + display: flex; + align-items: center; + justify-content: center; + font-size: 12px; + font-weight: 600; + cursor: pointer; +`;