Skip to content

Commit

Permalink
Merge pull request #590 from kbss-cvut/snackbar
Browse files Browse the repository at this point in the history
Added success snackbar to notify user when an event is successfully created/updated/removed
  • Loading branch information
blcham authored Sep 17, 2024
2 parents 0812141 + fd9c5a4 commit fd73730
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 fd73730

Please sign in to comment.