rudimentary feedback when uploading

This commit is contained in:
Erik 2022-03-22 20:26:03 +02:00
parent e66606c627
commit 5d5eea7955
No known key found for this signature in database
GPG Key ID: FEFF4B220DDF5589

View File

@ -1,5 +1,4 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { logout } from "../util/Util";
import '../css/Upload.css'; import '../css/Upload.css';
const Upload = () => { const Upload = () => {
@ -7,8 +6,9 @@ const Upload = () => {
const [selectedFile, updateSelection] = useState(null); const [selectedFile, updateSelection] = useState(null);
const [clipname, updateName] = useState(''); const [clipname, updateName] = useState('');
const submit = async () => { const submit = async ({target: button}) => {
button.disabled = true;
const formData = new FormData(); const formData = new FormData();
formData.set('file', selectedFile, selectedFile.name); formData.set('file', selectedFile, selectedFile.name);
formData.set('name', clipname); formData.set('name', clipname);
@ -21,6 +21,9 @@ const Upload = () => {
credentials: 'include' credentials: 'include'
}); });
button.disabled = false;
updateSelection(null);
updateName('');
console.log(response); console.log(response);
}; };
@ -72,9 +75,6 @@ const Upload = () => {
</div> </div>
<div>
<button onClick={logout}>Logout</button>
</div>
</div> </div>
); );