From d89598bb0a943d49e1c4dfe6913e4065859831da Mon Sep 17 00:00:00 2001 From: Me1e Date: Tue, 1 Aug 2023 23:37:00 +0900 Subject: [PATCH] =?UTF-8?q?feat(report):=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/pages/report/index.tsx | 60 +++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/packages/nextjs/pages/report/index.tsx b/packages/nextjs/pages/report/index.tsx index 4355ed5..628b88b 100644 --- a/packages/nextjs/pages/report/index.tsx +++ b/packages/nextjs/pages/report/index.tsx @@ -1,7 +1,18 @@ import { CSSProperties, useEffect, useState } from "react"; import Image from "next/image"; import { useRouter } from "next/router"; -import { Box, Button, Container, FormControl, InputLabel, MenuItem, Select, TextField, css } from "@mui/material"; +import { + Box, + Button, + CircularProgress, + Container, + FormControl, + InputLabel, + MenuItem, + Select, + TextField, + css, +} from "@mui/material"; import { styled } from "@mui/system"; import type { NextPage } from "next"; import { useDropzone } from "react-dropzone"; @@ -33,8 +44,9 @@ function CreateNFTWhenContractExist() { const [files, setFiles] = useState([]); const [lat, setLat] = useState(0); const [lng, setLng] = useState(0); - const { address, isConnecting, isDisconnected } = useAccount(); + const { address } = useAccount(); const router = useRouter(); + const [isLoading, setIsLoading] = useState(false); const { getRootProps, getInputProps, isFocused, isDragAccept, isDragReject } = useDropzone({ maxFiles: 1, @@ -72,11 +84,11 @@ function CreateNFTWhenContractExist() { setAlertLevel(level); }; - async function handleType(e) { + async function handleType(e: any) { setType(e.target.value); } - const { writeAsync, isLoading, isMining } = useScaffoldContractWrite({ + const { writeAsync } = useScaffoldContractWrite({ contractName: "ERC721Token", functionName: "mintNFT", // For payable functions, expressed in ETH @@ -90,6 +102,7 @@ function CreateNFTWhenContractExist() { }); async function Write() { + setIsLoading(true); console.log("ipfs start"); const cid = await handleIpfs(); console.log("write start"); @@ -107,7 +120,7 @@ function CreateNFTWhenContractExist() { type, name, description, - image: image, + image, createdAt: Date.now(), lat, lng, @@ -115,7 +128,6 @@ function CreateNFTWhenContractExist() { const tokenURI = await ipfsUploadMetadata(metadataForUpload); const tokenURL = `https://${tokenURI}.ipfs.nftstorage.link`; - // await setCid(tokenURL); console.log("ipfs end"); return tokenURL; } @@ -146,6 +158,16 @@ function CreateNFTWhenContractExist() { return ( + {isLoading && ( + + + +
Thanks!
+
Your contribution will save many lives.
+
After about 15 seconds, you'll be sent home.
+
+
+ )} icn_report 제보하기 @@ -163,7 +185,6 @@ function CreateNFTWhenContractExist() { )} -