mirror of
https://github.com/UA-Fediland/synapse-admin.git
synced 2024-11-22 14:31:27 +00:00
Migrate useMutation
to useDelete
in devices.js
(#225)
* Migrate `useMutation` to `useDelete` in `devices.js` * Update deprecated `notify` call
This commit is contained in:
parent
a647c91f4f
commit
2e59190bd0
1 changed files with 7 additions and 19 deletions
|
@ -1,11 +1,5 @@
|
||||||
import React, { Fragment, useState } from "react";
|
import React, { Fragment, useState } from "react";
|
||||||
import {
|
import { Button, useDelete, useNotify, Confirm, useRefresh } from "react-admin";
|
||||||
Button,
|
|
||||||
useMutation,
|
|
||||||
useNotify,
|
|
||||||
Confirm,
|
|
||||||
useRefresh,
|
|
||||||
} from "react-admin";
|
|
||||||
import ActionDelete from "@material-ui/icons/Delete";
|
import ActionDelete from "@material-ui/icons/Delete";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
import { alpha } from "@material-ui/core/styles/colorManipulator";
|
import { alpha } from "@material-ui/core/styles/colorManipulator";
|
||||||
|
@ -34,7 +28,7 @@ export const DeviceRemoveButton = props => {
|
||||||
const refresh = useRefresh();
|
const refresh = useRefresh();
|
||||||
const notify = useNotify();
|
const notify = useNotify();
|
||||||
|
|
||||||
const [removeDevice, { loading }] = useMutation();
|
const [removeDevice, { isLoading }] = useDelete("devices");
|
||||||
|
|
||||||
if (!record) return null;
|
if (!record) return null;
|
||||||
|
|
||||||
|
@ -43,21 +37,15 @@ export const DeviceRemoveButton = props => {
|
||||||
|
|
||||||
const handleConfirm = () => {
|
const handleConfirm = () => {
|
||||||
removeDevice(
|
removeDevice(
|
||||||
{
|
{ payload: { id: record.id, user_id: record.user_id } },
|
||||||
type: "delete",
|
|
||||||
resource: "devices",
|
|
||||||
payload: {
|
|
||||||
id: record.id,
|
|
||||||
user_id: record.user_id,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
notify("resources.devices.action.erase.success");
|
notify("resources.devices.action.erase.success");
|
||||||
refresh();
|
refresh();
|
||||||
},
|
},
|
||||||
onFailure: () =>
|
onFailure: () => {
|
||||||
notify("resources.devices.action.erase.failure", "error"),
|
notify("resources.devices.action.erase.failure", { type: "error" });
|
||||||
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
|
@ -74,7 +62,7 @@ export const DeviceRemoveButton = props => {
|
||||||
</Button>
|
</Button>
|
||||||
<Confirm
|
<Confirm
|
||||||
isOpen={open}
|
isOpen={open}
|
||||||
loading={loading}
|
loading={isLoading}
|
||||||
onConfirm={handleConfirm}
|
onConfirm={handleConfirm}
|
||||||
onClose={handleDialogClose}
|
onClose={handleDialogClose}
|
||||||
title="resources.devices.action.erase.title"
|
title="resources.devices.action.erase.title"
|
||||||
|
|
Loading…
Reference in a new issue