-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes.txt
More file actions
74 lines (55 loc) · 1.52 KB
/
notes.txt
File metadata and controls
74 lines (55 loc) · 1.52 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
@todo
add messages animation
add gemini vision image reader
add game
<form onSubmit={submit}>
<input type="file" name="file" onChange={changeFile} ref={ref} />
<input type="submit" value="upload" />
</form>;
///////////////////////////////////////
const [file, setFile] = useState({});
const ref = useRef(null);
const changeFile = async (e) => {
setFile(e.target.files?.[0]);
if (file) {
toast.success("Uploaded Successfully!", {
position: toast.POSITION.TOP_LEFT,
className: "foo-bar",
});
} else {
toast.error("Uploading failed", {
position: toast.POSITION.TOP_LEFT,
className: "foo-bar",
});
}
};
// console.log(file);
// useEffect(() => {
// // Check if the file is defined before performing actions
// if (file) {
// console.log('File selected:', file);
// // Additional actions if needed
// }
// }, [file]);
const submit = async (e) => {
e.preventDefault();
if (!file) return;
try {
const data = new FormData();
data.set("file", file);
const res = await fetch("api/pdf-upload", {
method: "POST",
body: data,
});
if (!res.ok) throw new Error(await res.text());
ref.current && (ref.current.value = "");
console.log("SUbmitted");
} catch (e) {
console.error(e);
}
};
//Hardhat
- compile - npx hardhat compile
- run local blockchain = npx hardhat node
- deploy to local network = npx hardhat run --network localhost scripts/deploy.js
- deploy to blockchain = npx hardhat run scripts/deploy.js --network <network-name>