diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-06-21 17:42:00 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-06-21 17:42:00 -0700 |
commit | d3a027a92958371acaf35d300770a4c864df7231 (patch) | |
tree | 0f6d28e5cd6603231f7db0c0d9d407687b649cbc /modern/src/RemoveDialog.js | |
parent | 0de52345ecb1bc9137a3d5df1fe753917b677314 (diff) | |
download | trackermap-web-d3a027a92958371acaf35d300770a4c864df7231.tar.gz trackermap-web-d3a027a92958371acaf35d300770a4c864df7231.tar.bz2 trackermap-web-d3a027a92958371acaf35d300770a4c864df7231.zip |
Implement device removal
Diffstat (limited to 'modern/src/RemoveDialog.js')
-rw-r--r-- | modern/src/RemoveDialog.js | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/modern/src/RemoveDialog.js b/modern/src/RemoveDialog.js index 14952e64..bca936f4 100644 --- a/modern/src/RemoveDialog.js +++ b/modern/src/RemoveDialog.js @@ -7,18 +7,28 @@ 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); + } + }); + } + return ( - <Dialog - open={props.open} - onClose={() => { props.onClose() }}> - <DialogContent> - <DialogContentText>{t('sharedRemoveConfirm')}</DialogContentText> - </DialogContent> - <DialogActions> - <Button color="primary">{t('sharedRemove')}</Button> - <Button color="primary" autoFocus>{t('sharedCancel')}</Button> - </DialogActions> - </Dialog> + <> + <Dialog + open={props.open} + onClose={() => { props.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> + </DialogActions> + </Dialog> + </> ); }; |