Skip to content

Commit

Permalink
UI: Object removal message (#802)
Browse files Browse the repository at this point in the history
Add removed object message
  • Loading branch information
KWMORALE committed Apr 24, 2023
1 parent 64315a6 commit c0e8d3d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions mwdb/web/src/components/ShowObject/Actions/RemoveAction.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ import { faTrash } from "@fortawesome/free-solid-svg-icons";
import { APIContext } from "@mwdb-web/commons/api";
import { AuthContext, Capability } from "@mwdb-web/commons/auth";
import { ObjectContext } from "@mwdb-web/commons/context";
import { ObjectAction, ConfirmationModal } from "@mwdb-web/commons/ui";
import {
ObjectAction,
ConfirmationModal,
useViewAlert,
} from "@mwdb-web/commons/ui";

export default function RemoveAction() {
const api = useContext(APIContext);
const auth = useContext(AuthContext);
const context = useContext(ObjectContext);
const navigate = useNavigate();
const { redirectToAlert } = useViewAlert();

const [isDeleteModalOpen, setDeleteModalOpen] = useState(false);
const [disabledModalButton, setDisabledModalButton] = useState(false);
Expand All @@ -21,7 +25,10 @@ export default function RemoveAction() {
setDisabledModalButton(true);
try {
await api.removeObject(context.object.id);
navigate(context.searchEndpoint);
redirectToAlert({
target: context.searchEndpoint,
success: "Object was successfully removed",
});
} catch (error) {
setDisabledModalButton(false);
setDeleteModalOpen(false);
Expand Down

0 comments on commit c0e8d3d

Please sign in to comment.