Replace react-hotkeys-hook with react-hotkeys

This commit is contained in:
Deluan
2021-02-02 22:15:13 -05:00
committed by Deluan Quintão
parent 8e02659441
commit 9959862791
7 changed files with 94 additions and 110 deletions
+20 -11
View File
@@ -1,7 +1,8 @@
import React from 'react'
import { useSelector } from 'react-redux'
import { Layout } from 'react-admin'
import React, { useCallback } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { Layout, toggleSidebar } from 'react-admin'
import { makeStyles } from '@material-ui/core/styles'
import { HotKeys } from 'react-hotkeys'
import Menu from './Menu'
import AppBar from './AppBar'
import Notification from './Notification'
@@ -15,15 +16,23 @@ export default (props) => {
const theme = useSelector((state) => themes[state.theme] || themes.DarkTheme)
const queue = useSelector((state) => state.queue)
const classes = useStyles({ addPadding: queue.queue.length > 0 })
const dispatch = useDispatch()
const keyMap = { TOGGLE_MENU: 'm' }
const keyHandlers = {
TOGGLE_MENU: useCallback(() => dispatch(toggleSidebar()), [dispatch]),
}
return (
<Layout
{...props}
className={classes.root}
menu={Menu}
appBar={AppBar}
theme={theme}
notification={Notification}
/>
<HotKeys handlers={keyHandlers} keyMap={keyMap}>
<Layout
{...props}
className={classes.root}
menu={Menu}
appBar={AppBar}
theme={theme}
notification={Notification}
/>
</HotKeys>
)
}