aboutsummaryrefslogtreecommitdiff
path: root/modern/src/RemoveDialog.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-06-21 17:42:00 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-06-21 17:42:00 -0700
commitd3a027a92958371acaf35d300770a4c864df7231 (patch)
tree0f6d28e5cd6603231f7db0c0d9d407687b649cbc /modern/src/RemoveDialog.js
parent0de52345ecb1bc9137a3d5df1fe753917b677314 (diff)
downloadetbsa-traccar-web-d3a027a92958371acaf35d300770a4c864df7231.tar.gz
etbsa-traccar-web-d3a027a92958371acaf35d300770a4c864df7231.tar.bz2
etbsa-traccar-web-d3a027a92958371acaf35d300770a4c864df7231.zip
Implement device removal
Diffstat (limited to 'modern/src/RemoveDialog.js')
-rw-r--r--modern/src/RemoveDialog.js32
1 files changed, 21 insertions, 11 deletions
diff --git a/modern/src/RemoveDialog.js b/modern/src/RemoveDialog.js
index 14952e6..bca936f 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>
+ </>
);
};