Skip to content

Commit

Permalink
[New #589] Added success snackbar to notify user when an event is suc…
Browse files Browse the repository at this point in the history
…cessfully created/updated/removed
  • Loading branch information
LaChope committed Sep 16, 2024
1 parent 0812141 commit fd9c5a4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/components/editor/faultTree/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -135,6 +135,7 @@ const Editor = () => {
const handleEventCreate = (newEvent: FaultEvent) => {
setSidebarSelectedEvent(newEvent);
refreshTree();
showSnackbar("Event created", SnackbarType.SUCCESS);
};

const handleEventUpdate = (eventToUpdate: FaultEvent) => {
Expand All @@ -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));
};

Expand All @@ -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));
};

Expand Down

0 comments on commit fd9c5a4

Please sign in to comment.