aboutsummaryrefslogtreecommitdiff
path: root/src/components/tables/item-table.js
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-12-04 21:37:52 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-12-04 21:37:52 +0530
commit1139da4da7f1bb0ee4a66d420e690beed36832c2 (patch)
treeb0e5fca2f13c691b0c42543d98a747289f527e52 /src/components/tables/item-table.js
parentbb38d843de17bb0b206a663e008c5dbb37f04708 (diff)
added notification system
Diffstat (limited to 'src/components/tables/item-table.js')
-rw-r--r--src/components/tables/item-table.js20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/components/tables/item-table.js b/src/components/tables/item-table.js
index 2fb7210..1b47f6f 100644
--- a/src/components/tables/item-table.js
+++ b/src/components/tables/item-table.js
@@ -17,6 +17,9 @@
import './scss/table.scss';
import { deleteItem } from './../../classes/item';
+import { notificationConfig } from "./../../classes/notifications";
+
+import { Store } from "react-notifications-component";
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faPencil, faTrashCan } from '@fortawesome/free-solid-svg-icons'
@@ -27,15 +30,24 @@ const ItemTable = (props) => {
const handleDelete = (i) => {
// TODO: add confirmation prompt
- deleteItem(i.Id, handleDelSuccess, handleDelFail);
+ deleteItem(i.Id, () => handleDelSuccess(i), err => handleDelFail(i, err));
}
- const handleDelSuccess = () => {
+ const handleDelSuccess = i => {
+ Store.addNotification({
+ title: "Successfully deleted item!",
+ message: `Item '${i.Name}' has successfully been deleted.`,
+ ...notificationConfig("success")
+ });
props.refresh();
}
- const handleDelFail = () => {
- alert("fail")
+ const handleDelFail = (i, err) => {
+ Store.addNotification({
+ title: "An error occoured",
+ message: `Failed to delete item '${i.Name}'. ${err.message}`,
+ ...notificationConfig("danger")
+ });
}
return (