From 37dd8129f8e07d00eb93262210bf1ecd4ce95532 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 20 Sep 2020 22:39:04 -0700 Subject: Refactor collection editing --- modern/src/RemoveDialog.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'modern/src/RemoveDialog.js') diff --git a/modern/src/RemoveDialog.js b/modern/src/RemoveDialog.js index bca936f..57be787 100644 --- a/modern/src/RemoveDialog.js +++ b/modern/src/RemoveDialog.js @@ -6,26 +6,25 @@ import DialogActions from '@material-ui/core/DialogActions'; import DialogContent from '@material-ui/core/DialogContent'; import DialogContentText from '@material-ui/core/DialogContentText'; -const RemoveDialog = (props) => { - const handleRemove = () => { - fetch(`/api/devices/${props.deviceId}`, { method: 'DELETE' }).then(response => { - if (response.ok) { - props.onResult(true); - } - }); - } +const RemoveDialog = ({ open, endpoint, itemId, onResult }) => { + const handleRemove = async () => { + const response = fetch(`/api/${endpoint}/${itemId}`, { method: 'DELETE' }) + if (response.ok) { + onResult(true); + } + }; return ( <> { props.onResult(false) }}> + open={open} + onClose={() => { onResult(false) }}> {t('sharedRemoveConfirm')} - + -- cgit v1.2.3