From d14e5d6fa7d0d1783350f13cf0a90c304c26ee85 Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Tue, 19 Jan 2021 12:23:05 +0200 Subject: [PATCH] fix:globalhotkeys & quick new. --- client/src/common/quickNewOptions.js | 12 ++++++------ .../src/components/Dashboard/GlobalHotkeys.js | 18 ++++++------------ .../QuickNewDropdown/QuickNewDropdown.js | 4 ++-- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/client/src/common/quickNewOptions.js b/client/src/common/quickNewOptions.js index 5ad34c5de..afcec73ef 100644 --- a/client/src/common/quickNewOptions.js +++ b/client/src/common/quickNewOptions.js @@ -1,8 +1,8 @@ export default [ - { id: 'invoices', name: 'Sale invoice', label: 'Shift+I' }, - { id: 'Purchase invoice', name: 'Purchase invoice' }, - { id: 'manual-journals', name: 'Manual journal', label: 'Shift+M' }, - { id: 'expenses', name: 'Expense', label: 'Shift+X' }, - { id: 'customers', name: 'Customer', label: 'Shift+C' }, - { id: 'vendors', name: 'Vendor', label: 'Shift+V' }, + { path: 'invoices/new', name: 'Sale invoice', label: 'Ctrl+Shift+I' }, + { path: 'bill//new', name: 'Purchase invoice',label:'Ctrl+Shift+B' }, + { path: 'make-journal-entry', name: 'Manual journal', label: 'Ctrl+Shift+M' }, + { path: 'expenses/new', name: 'Expense', label: 'Ctrl+Shift+X' }, + { path: 'customers/new', name: 'Customer', label: 'Ctrl+Shift+C' }, + { path: 'vendors/new', name: 'Vendor', label: 'Ctrl+Shift+V' }, ]; diff --git a/client/src/components/Dashboard/GlobalHotkeys.js b/client/src/components/Dashboard/GlobalHotkeys.js index 13b30623d..353c1c755 100644 --- a/client/src/components/Dashboard/GlobalHotkeys.js +++ b/client/src/components/Dashboard/GlobalHotkeys.js @@ -5,25 +5,19 @@ import routes from 'routes/dashboard'; import withDashboardActions from 'containers/Dashboard/withDashboardActions'; import { compose } from 'utils'; - function GlobalHotkeys({ // #withDashboardActions toggleSidebarExpend, - recordSidebarPreviousExpand, }) { const history = useHistory(); - const globalHotkeys = (function (array) { - const result = []; - array.forEach(({ hotkey }) => - typeof hotkey !== 'undefined' ? result.push(hotkey) : null, - ); - return result.toString(); - })(routes); - - const handleSidebarToggleBtn = () => { + const globalHotkeys = routes + .filter(({ hotkey }) => hotkey) + .map(({ hotkey }) => hotkey) + .toString(); + + const handleSidebarToggleBtn = () => { toggleSidebarExpend(); - recordSidebarPreviousExpand(); }; useHotkeys( globalHotkeys, diff --git a/client/src/containers/QuickNewDropdown/QuickNewDropdown.js b/client/src/containers/QuickNewDropdown/QuickNewDropdown.js index 0d9cdc982..9e82291f1 100644 --- a/client/src/containers/QuickNewDropdown/QuickNewDropdown.js +++ b/client/src/containers/QuickNewDropdown/QuickNewDropdown.js @@ -12,8 +12,8 @@ import quickNewOptions from 'common/quickNewOptions'; function QuickNewDropdown() { const history = useHistory(); - const handleClickQuickNew = ({ id }) => { - history.push(`/${id}`); + const handleClickQuickNew = ({path }) => { + history.push(`/${path}`); }; return (