Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const deleteBlock = useCallback(async ({ plugin, deleteElement }) => {
const response = await deleteElement({
variables: {
id: plugin.id
}
});
const { error } = response.data.pageBuilder.deleteElement;
if (error) {
showSnackbar(error.message);
return;
}
unregisterPlugin(plugin.name);
showSnackbar("Block " + plugin.title + " successfully deleted.");
}, []);
showConfirmation(async () => {
const { plugin, refresh, id } = props;
const { data: res } = await client.mutate({
mutation: deleteElement,
variables: { id }
});
const { error } = res.pageBuilder.deleteElement;
if (error) {
return showSnackbar(error.message);
}
unregisterPlugin(plugin);
refresh();
showSnackbar(
<span>
Element <strong>{title}</strong> deleted!
</span>
);
})
}