diff options
Diffstat (limited to 'modern/src/RemoveDialog.js')
-rw-r--r-- | modern/src/RemoveDialog.js | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/modern/src/RemoveDialog.js b/modern/src/RemoveDialog.js index bca936f4..57be7871 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 ( <> <Dialog - open={props.open} - onClose={() => { props.onResult(false) }}> + open={open} + onClose={() => { onResult(false) }}> <DialogContent> <DialogContentText>{t('sharedRemoveConfirm')}</DialogContentText> </DialogContent> <DialogActions> <Button color="primary" onClick={handleRemove}>{t('sharedRemove')}</Button> - <Button autoFocus onClick={() => props.onResult(false)}>{t('sharedCancel')}</Button> + <Button autoFocus onClick={() => onResult(false)}>{t('sharedCancel')}</Button> </DialogActions> </Dialog> </> |