From 6ba5ae39db96886fdfd1974a8e548d226b116f27 Mon Sep 17 00:00:00 2001 From: dklimpel <5740567+dklimpel@users.noreply.github.com> Date: Tue, 6 Feb 2024 11:23:38 +0100 Subject: [PATCH] fix devices --- src/components/destinations.js | 2 +- src/components/devices.js | 8 +++++--- src/synapse/dataProvider.js | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/destinations.js b/src/components/destinations.js index 777a1d5..1b2e4cf 100644 --- a/src/components/destinations.js +++ b/src/components/destinations.js @@ -64,7 +64,7 @@ export const DestinationReconnectButton = props => { handleReconnect( "destinations", - { id: record.id }, + { id: record.id, previousData: record }, { onSuccess: () => { notify("ra.notification.updated", { diff --git a/src/components/devices.js b/src/components/devices.js index 905217e..27e36fb 100644 --- a/src/components/devices.js +++ b/src/components/devices.js @@ -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"); diff --git a/src/synapse/dataProvider.js b/src/synapse/dataProvider.js index db57ec7..4a7e3cb 100644 --- a/src/synapse/dataProvider.js +++ b/src/synapse/dataProvider.js @@ -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, }));