fix devices
This commit is contained in:
parent
61b29534e5
commit
6ba5ae39db
@ -64,7 +64,7 @@ export const DestinationReconnectButton = props => {
|
||||
|
||||
handleReconnect(
|
||||
"destinations",
|
||||
{ id: record.id },
|
||||
{ id: record.id, previousData: record },
|
||||
{
|
||||
onSuccess: () => {
|
||||
notify("ra.notification.updated", {
|
||||
|
@ -10,14 +10,14 @@ import {
|
||||
import ActionDelete from "@mui/icons-material/Delete";
|
||||
import { alpha, useTheme } from "@mui/material/styles";
|
||||
|
||||
export const DeviceRemoveButton = props => {
|
||||
export const DeviceRemoveButton = () => {
|
||||
const theme = useTheme();
|
||||
const record = useRecordContext();
|
||||
const [open, setOpen] = useState(false);
|
||||
const refresh = useRefresh();
|
||||
const notify = useNotify();
|
||||
|
||||
const [removeDevice, { isLoading }] = useDelete("devices");
|
||||
const [removeDevice, { isLoading }] = useDelete();
|
||||
|
||||
if (!record) return null;
|
||||
|
||||
@ -25,8 +25,10 @@ export const DeviceRemoveButton = props => {
|
||||
const handleDialogClose = () => setOpen(false);
|
||||
|
||||
const handleConfirm = () => {
|
||||
console.log(record);
|
||||
removeDevice(
|
||||
{ payload: { id: record.id, user_id: record.user_id } },
|
||||
"devices",
|
||||
{ id: record.id, previousData: record },
|
||||
{
|
||||
onSuccess: () => {
|
||||
notify("resources.devices.action.erase.success");
|
||||
|
@ -534,7 +534,7 @@ const dataProvider = {
|
||||
const res = resourceMap[resource];
|
||||
|
||||
if ("delete" in res) {
|
||||
const del = res["delete"](params);
|
||||
const del = res["delete"](params.previousData);
|
||||
const endpoint_url = homeserver + del.endpoint;
|
||||
return jsonClient(endpoint_url, {
|
||||
method: "method" in del ? del.method : "DELETE",
|
||||
@ -546,7 +546,7 @@ const dataProvider = {
|
||||
const endpoint_url = homeserver + res.path;
|
||||
return jsonClient(`${endpoint_url}/${params.id}`, {
|
||||
method: "DELETE",
|
||||
body: JSON.stringify(params.data, filterNullValues),
|
||||
body: JSON.stringify(params.previousData, filterNullValues),
|
||||
}).then(({ json }) => ({
|
||||
data: json,
|
||||
}));
|
||||
|
Loading…
Reference in New Issue
Block a user