diff options
author | Anton Tananaev <anton@traccar.org> | 2022-07-03 11:00:47 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-07-03 11:00:47 -0700 |
commit | 0fb931d6b2193891eb8cefd002ef941eb6daed75 (patch) | |
tree | 18f966fb2cc04b75f10305565de968f68d6036bb /modern/src/main/EventsDrawer.js | |
parent | 0ab655eb5c031e1a2aac18ef475aff6c7724b227 (diff) | |
download | trackermap-web-0fb931d6b2193891eb8cefd002ef941eb6daed75.tar.gz trackermap-web-0fb931d6b2193891eb8cefd002ef941eb6daed75.tar.bz2 trackermap-web-0fb931d6b2193891eb8cefd002ef941eb6daed75.zip |
Add simple events drawer
Diffstat (limited to 'modern/src/main/EventsDrawer.js')
-rw-r--r-- | modern/src/main/EventsDrawer.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/modern/src/main/EventsDrawer.js b/modern/src/main/EventsDrawer.js new file mode 100644 index 00000000..91d6e3db --- /dev/null +++ b/modern/src/main/EventsDrawer.js @@ -0,0 +1,55 @@ +import React from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { + Drawer, IconButton, List, ListItem, ListItemText, Toolbar, Typography, +} from '@mui/material'; +import { makeStyles } from '@mui/styles'; +import DeleteIcon from '@mui/icons-material/Delete'; +import { useTranslation } from '../common/components/LocalizationProvider'; +import { eventsActions } from '../store'; + +const useStyles = makeStyles((theme) => ({ + drawer: { + width: theme.dimensions.eventsDrawerWidth, + }, + header: { + flexGrow: 1, + }, +})); + +const EventsDrawer = ({ open, onClose }) => { + const classes = useStyles(); + const dispatch = useDispatch(); + const t = useTranslation(); + + const events = useSelector((state) => state.events.items); + + return ( + <Drawer + anchor="right" + open={open} + onClose={onClose} + > + <Toolbar> + <Typography variant="h6" className={classes.header}> + {t('reportEvents')} + </Typography> + <IconButton color="inherit" edge="end" onClick={() => dispatch(eventsActions.deleteAll())}> + <DeleteIcon /> + </IconButton> + </Toolbar> + <List className={classes.drawer} dense> + {events.map((event) => ( + <ListItem key={event.id}> + <ListItemText primary={event.attributes.message} /> + <IconButton size="small" onClick={() => dispatch(eventsActions.delete(event))}> + <DeleteIcon fontSize="small" className={classes.negative} /> + </IconButton> + </ListItem> + ))} + </List> + </Drawer> + ); +}; + +export default EventsDrawer; |