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/client-table.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/components/tables/client-table.js') 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 ( -- cgit v1.2.3