From 1139da4da7f1bb0ee4a66d420e690beed36832c2 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Sun, 4 Dec 2022 21:37:52 +0530 Subject: added notification system --- src/components/tables/brand-table.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/components/tables/brand-table.js') 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 ( -- cgit v1.2.3