From fd9c5a4f4853f24903b7124c2bd14f6eb0c44783 Mon Sep 17 00:00:00 2001 From: Max Chopart Date: Mon, 16 Sep 2024 11:21:13 +0200 Subject: [PATCH] [New #589] Added success snackbar to notify user when an event is successfully created/updated/removed --- src/components/editor/faultTree/Editor.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/editor/faultTree/Editor.tsx b/src/components/editor/faultTree/Editor.tsx index e461ee46..d5f6cb84 100644 --- a/src/components/editor/faultTree/Editor.tsx +++ b/src/components/editor/faultTree/Editor.tsx @@ -19,7 +19,7 @@ import * as joint from "jointjs"; import { Rectangle } from "@models/utils/Rectangle"; import { JOINTJS_NODE_MODEL } from "@components/editor/faultTree/shapes/constants"; import { FaultEventScenario } from "@models/faultEventScenario"; -import { useAppBar } from "../../../contexts/AppBarContext"; +import { useAppBar } from "@contexts/AppBarContext"; import { asArray } from "@utils/utils"; const Editor = () => { @@ -135,6 +135,7 @@ const Editor = () => { const handleEventCreate = (newEvent: FaultEvent) => { setSidebarSelectedEvent(newEvent); refreshTree(); + showSnackbar("Event created", SnackbarType.SUCCESS); }; const handleEventUpdate = (eventToUpdate: FaultEvent) => { @@ -146,7 +147,10 @@ const Editor = () => { faultEventService .update(eventToUpdate) - .then((value) => refreshTree()) + .then((value) => { + refreshTree(); + showSnackbar("Event updated", SnackbarType.SUCCESS); + }) .catch((reason) => showSnackbar(reason, SnackbarType.ERROR)); }; @@ -156,7 +160,10 @@ const Editor = () => { hideHighlightedBorders(); faultEventService .remove(eventToDelete.iri) - .then((value) => refreshTree()) + .then((value) => { + refreshTree(); + showSnackbar("Event deleted", SnackbarType.SUCCESS); + }) .catch((reason) => showSnackbar(reason, SnackbarType.ERROR)); };