MCPcopy Create free account
hub / github.com/Packstack-Tech/packstack / handleSubmit

Function handleSubmit

frontend/src/app/Inventory/UploadModal.tsx:17–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15 const [error, hasError] = React.useState<boolean>(false);
16
17 function handleSubmit() {
18 if (fileInput.current && fileInput.current.files) {
19 const file = fileInput.current.files[0];
20 if (!file) {
21 return;
22 }
23 const formData = new FormData();
24 formData.append('file', file, file.name);
25
26 setLoading(true);
27 upload(formData)
28 .then(() => {
29 alertSuccess({ message: 'Items successfully uploaded.' });
30 fetchItems();
31 setLoading(false);
32 hideModal();
33 hasError(false);
34 })
35 .catch(err => {
36 hasError(true);
37 setLoading(false);
38 });
39 }
40 }
41
42 const errorMsg = () => (
43 <Alert type="error"

Callers

nothing calls this directly

Calls 2

alertSuccessFunction · 0.90
fetchItemsFunction · 0.85

Tested by

no test coverage detected