-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathRemoveFileForm.js
More file actions
45 lines (40 loc) · 1.11 KB
/
RemoveFileForm.js
File metadata and controls
45 lines (40 loc) · 1.11 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
import React, { useState } from "react";
import { removeFile } from "../utils";
import { notify } from "./Notifications";
function RemoveFileForm(props) {
const [fileId, setFileId] = useState("");
const handleSubmit = async (e) => {
e.preventDefault();
try {
await removeFile(fileId);
notify(`File with ID ${fileId} has been removed.`);
setFileId("");
} catch (err) {
console.error(err);
notify(`Failed to remove file with ID ${fileId}.`, true);
}
};
return (
<div className="container">
<h2>Remove File</h2>
<form onSubmit={handleSubmit}>
<div className="form-group">
<label htmlFor="fileId">File ID:</label>
<input
type="text"
className="form-control"
id="fileId"
placeholder="Enter file ID"
value={fileId}
onChange={(e) => setFileId(e.target.value)}
required
/>
</div>
<button type="submit" className="btn btn-primary">
Remove
</button>
</form>
</div>
);
}
export default RemoveFileForm;