From 15bc34d866de679e0bb7e857ee1c38d0271e174e Mon Sep 17 00:00:00 2001 From: "a.bouhuolia" Date: Tue, 3 Aug 2021 11:02:03 +0200 Subject: [PATCH] feat: arabic localization. --- client/src/components/App.js | 2 +- client/src/components/Dashboard/Dashboard.js | 6 +- .../src/components/Dashboard/PrivatePages.js | 8 +- .../Dashboard/PrivatePagesProvider.js | 4 +- .../components/Preferences/PreferencesPage.js | 2 +- client/src/components/Sidebar/SidebarMenu.js | 114 +++++++++--------- .../src/components/SidebarOverlay/index.tsx | 10 +- client/src/config/sidebarMenu.js | 18 +-- client/src/containers/Items/ItemFormPage.js | 5 +- client/src/containers/Items/components.js | 2 - .../Purchases/Bills/BillForm/BillFormPage.js | 3 +- .../EstimateForm/EstimateFormPage.js | 3 +- .../Invoices/InvoiceForm/InvoiceFormPage.js | 3 +- .../PaymentReceiveFormPage.js | 5 +- .../Receipts/ReceiptForm/ReceiptFormPage.js | 3 +- client/src/lang/ar-ly/index.json | 75 +++++++++++- client/src/lang/en/index.json | 3 +- client/src/routes/dashboard.js | 1 + client/src/style/App.scss | 7 ++ 19 files changed, 185 insertions(+), 89 deletions(-) diff --git a/client/src/components/App.js b/client/src/components/App.js index f851f4234..aa79941ae 100644 --- a/client/src/components/App.js +++ b/client/src/components/App.js @@ -28,7 +28,7 @@ const queryConfig = { function GlobalFetchQuery({ children }) { - window.localStorage.setItem('lang', 'en'); + window.localStorage.setItem('lang', 'ar-ly'); return children } diff --git a/client/src/components/Dashboard/Dashboard.js b/client/src/components/Dashboard/Dashboard.js index a78a6f322..879fb77e3 100644 --- a/client/src/components/Dashboard/Dashboard.js +++ b/client/src/components/Dashboard/Dashboard.js @@ -17,8 +17,6 @@ import DrawersContainer from 'components/DrawersContainer'; * Dashboard page. */ export default function Dashboard() { - const dashboardContentRef = React.createRef(); - return ( @@ -31,8 +29,8 @@ export default function Dashboard() { - - + + diff --git a/client/src/components/Dashboard/PrivatePages.js b/client/src/components/Dashboard/PrivatePages.js index f49b356b7..0d0b5d06c 100644 --- a/client/src/components/Dashboard/PrivatePages.js +++ b/client/src/components/Dashboard/PrivatePages.js @@ -17,16 +17,16 @@ export default function DashboardPrivatePages() { return ( - {/* + - */} + - {/* */} + - {/* */} + diff --git a/client/src/components/Dashboard/PrivatePagesProvider.js b/client/src/components/Dashboard/PrivatePagesProvider.js index 1e67ce2bc..34db3a813 100644 --- a/client/src/components/Dashboard/PrivatePagesProvider.js +++ b/client/src/components/Dashboard/PrivatePagesProvider.js @@ -7,10 +7,10 @@ import { useCurrentOrganization } from '../../hooks/query/organization'; */ export function PrivatePagesProvider({ children }) { // Fetches the current user's organization. - // const { isLoading } = useCurrentOrganization(); + const { isLoading } = useCurrentOrganization(); return ( - + {children} ) diff --git a/client/src/components/Preferences/PreferencesPage.js b/client/src/components/Preferences/PreferencesPage.js index 599794233..a0e23dc97 100644 --- a/client/src/components/Preferences/PreferencesPage.js +++ b/client/src/components/Preferences/PreferencesPage.js @@ -16,7 +16,7 @@ import 'style/pages/Preferences/Page.scss'; export default function PreferencesPage() { return ( -
diff --git a/client/src/components/Sidebar/SidebarMenu.js b/client/src/components/Sidebar/SidebarMenu.js index 62164f715..02535cc50 100644 --- a/client/src/components/Sidebar/SidebarMenu.js +++ b/client/src/components/Sidebar/SidebarMenu.js @@ -1,7 +1,8 @@ -import React, { useMemo } from 'react'; -import { Menu, MenuDivider, Button } from '@blueprintjs/core'; +import React from 'react'; +import { Menu, MenuDivider } from '@blueprintjs/core'; import { useHistory, useLocation } from 'react-router-dom'; import sidebarMenuList from 'config/sidebarMenu'; +import { Choose } from 'components'; import Icon from 'components/Icon'; import MenuItem from 'components/MenuItem'; import { MenuItemLabel } from 'components'; @@ -11,6 +12,16 @@ import SidebarOverlay from 'components/SidebarOverlay'; const DEFAULT_ITEM = { text: '', href: '', +}; + +function matchPath(pathname, path, matchExact) { + return matchExact ? pathname === path : pathname.indexOf(path) !== -1; +} + +function SidebarMenuItemSpace({ space }) { + return ( +
+ ) } export default function SidebarMenu() { @@ -24,64 +35,60 @@ export default function SidebarMenu() { return list.map((item, index) => { const hasChildren = Array.isArray(item.children); - 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)) || currentItem ===item; + const isActive = + (item.children + ? item.children.some((c) => + matchPath(location.pathname, c.href, item.matchExact), + ) + : item.href && + matchPath(location.pathname, item.href, item.matchExact)) || + currentItem === item; const handleItemClick = () => { if (item.href) { history.push(item.href); } - setIsOpen(true); - setCurrentItem(item); + if (item.children && item.children.length > 0) { + setIsOpen(true); + setCurrentItem(item); + } else { + setIsOpen(false); + } }; - const maybeRenderLabel = (item) => - item.newTabHref ? ( -