From 0321f29442a3e9a3e2a3a1c99663a9c9ea0e9f97 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Tue, 24 Nov 2020 11:30:27 +0200 Subject: [PATCH] feat: rename item sku to code. feat: fix sidebar current tab issue. --- client/src/components/MenuItemLabel.js | 2 +- client/src/components/Sidebar/SidebarMenu.js | 29 ++++++++++++++----- client/src/config/sidebarMenu.js | 14 ++++++--- .../Entries/EditableItemsEntriesTable.js | 5 ++++ .../containers/Entries/ItemsEntriesTable.js | 4 +++ client/src/containers/Items/ItemForm.js | 2 +- .../src/containers/Items/ItemForm.schema.js | 7 +++-- client/src/containers/Items/ItemFormBody.js | 12 ++++---- .../Items/ItemFormPrimarySection.js | 4 +-- client/src/containers/Items/ItemsDataTable.js | 4 +-- .../src/containers/Purchases/Bill/BillForm.js | 7 +++-- .../Purchases/Bill/BillFormHeader.js | 1 + client/src/index.js | 8 ----- client/src/routes/dashboard.js | 12 ++++---- server/src/api/controllers/Items.ts | 2 +- .../20190822214306_create_items_table.js | 2 +- ...715194514_create_payment_receives_table.js | 2 +- ...1_create_payment_receives_entries_table.js | 2 +- ...00719153909_create_bills_payments_table.js | 2 +- server/src/interfaces/Item.ts | 4 +-- 20 files changed, 75 insertions(+), 50 deletions(-) diff --git a/client/src/components/MenuItemLabel.js b/client/src/components/MenuItemLabel.js index c11b9a2d2..ab0826f73 100644 --- a/client/src/components/MenuItemLabel.js +++ b/client/src/components/MenuItemLabel.js @@ -3,5 +3,5 @@ import React from 'react'; export default function MenuItemLabel({ text }) { - return ({ text }); + return ({ text }); } \ No newline at end of file diff --git a/client/src/components/Sidebar/SidebarMenu.js b/client/src/components/Sidebar/SidebarMenu.js index 4354e9e5e..6a41f891d 100644 --- a/client/src/components/Sidebar/SidebarMenu.js +++ b/client/src/components/Sidebar/SidebarMenu.js @@ -1,5 +1,5 @@ -import React from 'react'; -import { Menu, MenuDivider } from '@blueprintjs/core'; +import React, { useMemo } from 'react'; +import { Menu, MenuDivider, Button } from '@blueprintjs/core'; import { useHistory, useLocation } from 'react-router-dom'; import sidebarMenuList from 'config/sidebarMenu'; import Icon from 'components/Icon'; @@ -16,16 +16,31 @@ export default function SidebarMenu() { const children = Array.isArray(item.children) ? menuItemsMapper(item.children) : null; - const isActive = - (item.href && item.href === location.pathname) || - (item.children && - item.children.some((c) => c.href === location.pathname)); + + const matchPath = (pathname, path) => { + return item.matchExact ? pathname === path : pathname.indexOf(path) !== -1; + }; + const isActive = (item.children) ? + item.children.some((c) => matchPath(location.pathname, c.href)) : + (item.href && matchPath(location.pathname, item.href)); const handleItemClick = () => { if (item.href) { history.push(item.href); } }; + + const maybeRenderLabel = (item) => item.newTabHref ? ( +