-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.jsx
56 lines (50 loc) · 1.68 KB
/
index.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// import Head from "next/head";
import Image from "next/image";
import { useState, useEffect } from "react";
import { avatarNFTSTORAGE } from "../utils/web3utils";
import elfImage from "../public/elf-3600557344.png";
import PDFParser from "../components/PDFParser";
// import { createPrompt } from "../utils/promptGen";
import { Create } from "../components/Create";
export default function Home() {
const [data, setData] = useState({
race: "",
class: "",
});
const [imageProcessing, setImageProcessing] = useState(false); //processing state ie. loading...
const [error, setError] = useState(null); //error msg
const [imageResult, setImageResult] = useState(null); //url
const [nftStorageProcessing, setNftStorageProcessing] = useState(false); //processing state ie. loading...
const [CID, setCID] = useState(null); //url
// const [pdfData, setPdfData] = useState(null); //url
// const [prompt, setPrompt] = useState(null); //url
const setValue = (e) => {
setData({ ...data, [e.target.name]: e.target.value });
};
const send = async () => {
setImageProcessing(true);
};
const toggleImageProcessing = async () => {
setImageProcessing(false);
};
useEffect(() => {
if (imageProcessing) {
console.log(imageProcessing);
setTimeout(toggleImageProcessing, 3000);
}
}, [imageProcessing]);
const storeImage = async () => {
setNftStorageProcessing(true);
const cid = await avatarNFTSTORAGE(imageResult.imageUrl);
setNftStorageProcessing(false);
setCID(cid);
};
return (
<div id="bodytype">
<h1>D&D Diffusion</h1>
<div className="flex flex-col items-center">
<Create />
</div>
</div>
);
}