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/editors/brand-editor.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/components/editors/brand-editor.js') diff --git a/src/components/editors/brand-editor.js b/src/components/editors/brand-editor.js index 7796c68..2b7806e 100644 --- a/src/components/editors/brand-editor.js +++ b/src/components/editors/brand-editor.js @@ -16,8 +16,10 @@ */ import { Brand, saveBrand, editBrand } from './../../classes/brand' +import { notificationConfig } from "./../../classes/notifications"; import './scss/brand-editor.scss' +import { Store } from "react-notifications-component"; import { useState } from 'react'; const BrandEditor = (props) => { @@ -36,13 +38,22 @@ const BrandEditor = (props) => { } const handleSuccess = () => { + Store.addNotification({ + title: `Successfully ${props.editing ? "edited" : "added"} brand!`, + message: `${name} has successfully been ${props.editing ? "edited" : "saved"}.`, + ...notificationConfig("success") + }); clearAll(); props.callback(); props.editing && props.hide(); } - const handleFail = () => { - alert("fail"); + const handleFail = err => { + Store.addNotification({ + title: "An error occoured", + message: `Failed to ${props.editing ? "edit" : "add"} brand '${name}'. ${err.message}`, + ...notificationConfig("danger") + }); } const clearAll = () => { -- cgit v1.2.3