aboutsummaryrefslogtreecommitdiff
path: root/src/components/tables
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/tables')
-rw-r--r--src/components/tables/brand-table.js20
-rw-r--r--src/components/tables/client-table.js24
-rw-r--r--src/components/tables/item-table.js20
3 files changed, 50 insertions, 14 deletions
diff --git a/src/components/tables/brand-table.js b/src/components/tables/brand-table.js
index db8272c..3b38a5c 100644
--- a/src/components/tables/brand-table.js
+++ b/src/components/tables/brand-table.js
@@ -17,6 +17,9 @@
import './scss/brand-table.scss';
import { deleteBrand } from './../../classes/brand';
+import { notificationConfig } from "./../../classes/notifications";
+
+import { Store } from "react-notifications-component";
const BrandTable = (props) => {
const handleEdit = (b) => {
@@ -25,15 +28,24 @@ const BrandTable = (props) => {
const handleDelete = (b) => {
// TODO: add confirmation prompt
- deleteBrand(b.Id, handleDelSuccess, handleDelFail);
+ deleteBrand(b.Id, () => handleDelSuccess(b), err => handleDelFail(b, err));
}
- const handleDelSuccess = () => {
+ const handleDelSuccess = b => {
+ Store.addNotification({
+ title: "Successfully deleted brand!",
+ message: `Brand '${b.Name}' has successfully been deleted.`,
+ ...notificationConfig("success")
+ });
props.refresh();
}
- const handleDelFail = () => {
- alert("fail")
+ const handleDelFail = (b, err) => {
+ Store.addNotification({
+ title: "An error occoured",
+ message: `Failed to delete brand '${b.Name}'. ${err.message}`,
+ ...notificationConfig("danger")
+ });
}
return (
diff --git a/src/components/tables/client-table.js b/src/components/tables/client-table.js
index cea612d..1f51c88 100644
--- a/src/components/tables/client-table.js
+++ b/src/components/tables/client-table.js
@@ -17,23 +17,35 @@
import './scss/client-table.scss';
import { deleteClient } from './../../classes/client';
+import { notificationConfig } from "./../../classes/notifications";
+
+import { Store } from "react-notifications-component";
const ClientTable = (props) => {
- const handleEdit = (c) => {
+ const handleEdit = c => {
props.setClientToEdit(c)
}
- const handleDelete = (c) => {
+ const handleDelete = c => {
// TODO: add confirmation prompt
- deleteClient(c.Id, handleDelSuccess, handleDelFail);
+ deleteClient(c.Id, () => handleDelSuccess(c), err => handleDelFail(c, err));
}
- const handleDelSuccess = () => {
+ const handleDelSuccess = c => {
+ Store.addNotification({
+ title: "Successfully deleted client!",
+ message: `Client '${c.Name}' has successfully been deleted.`,
+ ...notificationConfig("success")
+ });
props.refresh();
}
- const handleDelFail = () => {
- alert("fail")
+ const handleDelFail = (c, err) => {
+ Store.addNotification({
+ title: "An error occoured",
+ message: `Failed to delete client '${c.Name}'. ${err.message}`,
+ ...notificationConfig("danger")
+ });
}
return (
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 (