implement the deletion of tokens

This commit is contained in:
Dieter Stinglhamber 2021-10-11 16:23:18 +02:00
parent b4ba83cd99
commit cfe351fb43

View File

@ -81,6 +81,27 @@ const ApiTokenListView = () => {
}
);
const deleteMutation = useMutation(
async id => {
await axiosInstance.delete(`/admin/api-tokens/${id}`);
},
{
onSuccess: async () => {
await queryClient.invalidateQueries(['api-tokens']);
},
onError: err => {
if (err?.response?.data?.data) {
toggleNotification({ type: 'warning', message: err.response.data.data });
} else {
toggleNotification({
type: 'warning',
message: { id: 'notification.error', defaultMessage: 'An error occured' },
});
}
},
}
);
const shouldDisplayDynamicTable = canRead && apiTokens;
const shouldDisplayNoContent = canRead && !apiTokens && !canCreate;
const shouldDisplayNoContentWithCreationButton = canRead && !apiTokens && canCreate;