aboutsummaryrefslogtreecommitdiff
path: root/modern/src/RemoveDialog.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-09-20 22:39:04 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-09-20 22:39:04 -0700
commit37dd8129f8e07d00eb93262210bf1ecd4ce95532 (patch)
tree80f115342fb4624675856a9164970b81f1f5b263 /modern/src/RemoveDialog.js
parent787c9dc0ec684d3524ec060b6422ffbaea5012ac (diff)
downloadtrackermap-web-37dd8129f8e07d00eb93262210bf1ecd4ce95532.tar.gz
trackermap-web-37dd8129f8e07d00eb93262210bf1ecd4ce95532.tar.bz2
trackermap-web-37dd8129f8e07d00eb93262210bf1ecd4ce95532.zip
Refactor collection editing
Diffstat (limited to 'modern/src/RemoveDialog.js')
-rw-r--r--modern/src/RemoveDialog.js21
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>
</>