{hasSubMenu && (openSidebar || window.innerWidth > 1139) && (
-
- {subMenuName === "services" ? (
-
- ) : subMenuName === "receipts" ? (
-
- ) : subMenuName === "customers" ? (
-
- ) : subMenuName === "tickets" ? (
-
- ) : subMenuName === "users" ? (
-
- ) : subMenuName === "learning" ? (
-
- ) : subMenuName === "blog" ? (
-
- ) : subMenuName === "support" ? (
-
- ) : subMenuName === "accessLogs" ? (
-
+
+ {subMenuName === "menu" ? (
+
+ ) : subMenuName === "financial" ? (
+
+ ) : subMenuName === "other" ? (
+
+ ) : subMenuName === "content" ? (
+
+ ) : subMenuName === "reseller" ? (
+
+ ) : subMenuName === "dmenu" ? (
+
+ ) : subMenuName === "dkala" ? (
+
+ ) : subMenuName === "dpage" ? (
+
+ ) : subMenuName === "dmail" ? (
+
) : null}
)}
diff --git a/src/shared/components/AccessLogsSubMenu.tsx b/src/shared/components/AccessLogsSubMenu.tsx
deleted file mode 100644
index cb1085a..0000000
--- a/src/shared/components/AccessLogsSubMenu.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { FC } from 'react'
-import { useTranslation } from 'react-i18next'
-import { useLocation } from 'react-router-dom'
-import { Pages } from '../../config/Pages'
-import SideBarItem from '../SideBarItem'
-import { DocumentText, Activity, Warning2, Shield } from 'iconsax-react'
-
-const AccessLogsSubMenu: FC = () => {
- const { t } = useTranslation('global')
- const location = useLocation()
- const iconSizeSideBar = 20
-
- const isActive = (name: string) => {
- return location.pathname.includes(name)
- }
-
- return (
-
-
- {t('sidebar.accessLogs')}
-
-
-
-
- }
- title="لیست لاگها"
- isActive={isActive('access-logs/list')}
- link={Pages.accessLogs.list}
- activeName='access_logs_list'
- />
-
- }
- title="آمار لاگها"
- isActive={isActive('access-logs/stats')}
- link={Pages.accessLogs.stats}
- activeName='access_logs_stats'
- />
-
- }
- title="لاگهای خطا"
- isActive={isActive('access-logs/errors')}
- link={Pages.accessLogs.errors}
- activeName='access_logs_errors'
- />
-
- }
- title="لاگهای مجوز"
- isActive={isActive('access-logs/permissions')}
- link={Pages.accessLogs.permissions}
- activeName='access_logs_permissions'
- />
-
-
-
- )
-}
-
-export default AccessLogsSubMenu
diff --git a/src/shared/components/BlogSubMenu.tsx b/src/shared/components/BlogSubMenu.tsx
deleted file mode 100644
index 4f108f7..0000000
--- a/src/shared/components/BlogSubMenu.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import { DocumentText } from 'iconsax-react'
-import { FC } from 'react'
-import { useTranslation } from 'react-i18next'
-import SubMenuItem from './SubMenuItem'
-import { Pages } from '../../config/Pages'
-
-const BlogSubMenu: FC = () => {
-
- const { t } = useTranslation('global')
-
- const isActive = (name: string) => {
- return location.pathname.includes(name)
- }
-
- return (
-
-
-
-
- {t('sidebar.blog')}
-
-
-
-
-
-
-
-
-
-
- )
-}
-
-export default BlogSubMenu
\ No newline at end of file
diff --git a/src/shared/components/ContentSubMenu.tsx b/src/shared/components/ContentSubMenu.tsx
new file mode 100644
index 0000000..c6d218d
--- /dev/null
+++ b/src/shared/components/ContentSubMenu.tsx
@@ -0,0 +1,95 @@
+import { DocumentLike } from "iconsax-react";
+import { FC } from "react";
+import { useTranslation } from "react-i18next";
+import { useLocation } from "react-router-dom";
+import { Pages } from "../../config/Pages";
+import SubMenuAccordion from "./SubMenuAccordion";
+import SubMenuItem from "./SubMenuItem";
+
+const ContentSubMenu: FC = () => {
+ const location = useLocation();
+ const { t } = useTranslation("global");
+
+ const isActive = (name: string) => location.pathname.includes(name);
+
+ return (
+
+
+
+
{t("sidebar.mnage_content")}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default ContentSubMenu;
diff --git a/src/shared/components/CustomerSubMenu.tsx b/src/shared/components/CustomerSubMenu.tsx
deleted file mode 100644
index bbb2a54..0000000
--- a/src/shared/components/CustomerSubMenu.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import { People } from 'iconsax-react'
-import { FC } from 'react'
-import { useTranslation } from 'react-i18next'
-import SubMenuItem from './SubMenuItem'
-import { Pages } from '../../config/Pages'
-
-const CustomerSubMenu: FC = () => {
-
- const { t } = useTranslation('global')
-
- const isActive = (name: string) => {
- return location.pathname.includes(name)
- }
-
- return (
-
-
-
-
- {t('sidebar.customers')}
-
-
-
-
-
-
-
-
-
-
- )
-}
-
-export default CustomerSubMenu
\ No newline at end of file
diff --git a/src/shared/components/DkalaSubMenu.tsx b/src/shared/components/DkalaSubMenu.tsx
new file mode 100644
index 0000000..2722120
--- /dev/null
+++ b/src/shared/components/DkalaSubMenu.tsx
@@ -0,0 +1,61 @@
+import { Building } from "iconsax-react";
+import { FC } from "react";
+import { useTranslation } from "react-i18next";
+import { useLocation } from "react-router-dom";
+import { Pages } from "../../config/Pages";
+import SubMenuItem from "./SubMenuItem";
+
+const DkalaSubMenu: FC = () => {
+ const location = useLocation();
+ const { t } = useTranslation("global");
+
+ const isActive = (name: string) => location.pathname.includes(name);
+
+ return (
+
+
+
+
{t("sidebar.dkala")}
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default DkalaSubMenu;
diff --git a/src/shared/components/DmailSubMenu.tsx b/src/shared/components/DmailSubMenu.tsx
new file mode 100644
index 0000000..a231ea0
--- /dev/null
+++ b/src/shared/components/DmailSubMenu.tsx
@@ -0,0 +1,37 @@
+import { Global } from "iconsax-react";
+import { FC } from "react";
+import { useTranslation } from "react-i18next";
+import { useLocation } from "react-router-dom";
+import { Pages } from "../../config/Pages";
+import SubMenuItem from "./SubMenuItem";
+
+const DmailSubMenu: FC = () => {
+ const location = useLocation();
+ const { t } = useTranslation("global");
+
+ const isActive = (name: string) => location.pathname.includes(name);
+
+ return (
+
+
+
+
{t("sidebar.dmail")}
+
+
+
+
+
+
+ );
+};
+
+export default DmailSubMenu;
diff --git a/src/shared/components/DmenuSubMenu.tsx b/src/shared/components/DmenuSubMenu.tsx
new file mode 100644
index 0000000..743f6df
--- /dev/null
+++ b/src/shared/components/DmenuSubMenu.tsx
@@ -0,0 +1,61 @@
+import { Building } from "iconsax-react";
+import { FC } from "react";
+import { useTranslation } from "react-i18next";
+import { useLocation } from "react-router-dom";
+import { Pages } from "../../config/Pages";
+import SubMenuItem from "./SubMenuItem";
+
+const DmenuSubMenu: FC = () => {
+ const location = useLocation();
+ const { t } = useTranslation("global");
+
+ const isActive = (name: string) => location.pathname.includes(name);
+
+ return (
+
+
+
+
{t("sidebar.dmenu")}
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default DmenuSubMenu;
diff --git a/src/shared/components/DpageSubMenu.tsx b/src/shared/components/DpageSubMenu.tsx
new file mode 100644
index 0000000..26d20c5
--- /dev/null
+++ b/src/shared/components/DpageSubMenu.tsx
@@ -0,0 +1,37 @@
+import { Gallery } from "iconsax-react";
+import { FC } from "react";
+import { useTranslation } from "react-i18next";
+import { useLocation } from "react-router-dom";
+import { Pages } from "../../config/Pages";
+import SubMenuItem from "./SubMenuItem";
+
+const DpageSubMenu: FC = () => {
+ const location = useLocation();
+ const { t } = useTranslation("global");
+
+ const isActive = (name: string) => location.pathname.includes(name);
+
+ return (
+
+
+
+
{t("sidebar.dpage")}
+
+
+
+
+
+
+ );
+};
+
+export default DpageSubMenu;
diff --git a/src/shared/components/FinancialSubMenu.tsx b/src/shared/components/FinancialSubMenu.tsx
new file mode 100644
index 0000000..8714ae7
--- /dev/null
+++ b/src/shared/components/FinancialSubMenu.tsx
@@ -0,0 +1,74 @@
+import { Money3 } from "iconsax-react";
+import { FC } from "react";
+import { useTranslation } from "react-i18next";
+import { useLocation } from "react-router-dom";
+import { Pages } from "../../config/Pages";
+import SubMenuAccordion from "./SubMenuAccordion";
+import SubMenuItem from "./SubMenuItem";
+
+const FinancialSubMenu: FC = () => {
+ const location = useLocation();
+ const { t } = useTranslation("global");
+
+ const isActive = (name: string) => location.pathname.includes(name);
+
+ return (
+
+
+
+
{t("sidebar.financial")}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default FinancialSubMenu;
diff --git a/src/shared/components/LearningSubMenu.tsx b/src/shared/components/LearningSubMenu.tsx
deleted file mode 100644
index 663e74a..0000000
--- a/src/shared/components/LearningSubMenu.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import { Teacher } from 'iconsax-react'
-import { FC } from 'react'
-import { useTranslation } from 'react-i18next'
-import SubMenuItem from './SubMenuItem'
-import { useLocation } from 'react-router-dom'
-import { Pages } from '../../config/Pages'
-
-const LearningSubMenu: FC = () => {
-
- const { t } = useTranslation('global')
- const location = useLocation()
-
- const isActive = (name: string) => {
- return location.pathname.includes(name)
- }
-
- return (
-
-
-
-
- {t('sidebar.learning')}
-
-
-
-
-
-
-
-
-
-
- )
-}
-
-export default LearningSubMenu
\ No newline at end of file
diff --git a/src/shared/components/MenuSubMenu.tsx b/src/shared/components/MenuSubMenu.tsx
new file mode 100644
index 0000000..cc8c5f6
--- /dev/null
+++ b/src/shared/components/MenuSubMenu.tsx
@@ -0,0 +1,176 @@
+import { Element3 } from "iconsax-react";
+import { FC } from "react";
+import { useTranslation } from "react-i18next";
+import { useLocation } from "react-router-dom";
+import { Pages } from "../../config/Pages";
+import { useGetProfile } from "../../pages/profile/hooks/useProfileData";
+import SubMenuAccordion from "./SubMenuAccordion";
+import SubMenuItem from "./SubMenuItem";
+
+const MenuSubMenu: FC = () => {
+ const location = useLocation();
+ const { t } = useTranslation("global");
+ const { data: profile } = useGetProfile();
+
+ const isActive = (name: string) => location.pathname.includes(name);
+
+ return (
+
+
+
+
{t("sidebar.menu")}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {profile?.data?.user?.roles?.some((role: { name: string }) => role.name === "super_admin") && (
+
+ )}
+
+
+ );
+};
+
+export default MenuSubMenu;
diff --git a/src/shared/components/OtherSubMenu.tsx b/src/shared/components/OtherSubMenu.tsx
new file mode 100644
index 0000000..1cb69cf
--- /dev/null
+++ b/src/shared/components/OtherSubMenu.tsx
@@ -0,0 +1,108 @@
+import { Category } from "iconsax-react";
+import { FC } from "react";
+import { useTranslation } from "react-i18next";
+import { useLocation } from "react-router-dom";
+import { Pages } from "../../config/Pages";
+import SubMenuAccordion from "./SubMenuAccordion";
+import SubMenuItem from "./SubMenuItem";
+
+const OtherSubMenu: FC = () => {
+ const location = useLocation();
+ const { t } = useTranslation("global");
+
+ const isActive = (name: string) => location.pathname.includes(name);
+
+ const isTaskManagerActive =
+ location.pathname.startsWith(Pages.taskmanager.workspace) ||
+ location.pathname === Pages.taskmanager.workspaceList ||
+ location.pathname.startsWith(Pages.taskmanager.updateWorkspace) ||
+ location.pathname === Pages.taskmanager.createWorkspace ||
+ location.pathname === Pages.taskmanager.createProject ||
+ location.pathname.startsWith(Pages.taskmanager.updateProject) ||
+ location.pathname.startsWith(Pages.taskmanager.projectList);
+
+ return (
+
+
+
+
{t("sidebar.other")}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default OtherSubMenu;
diff --git a/src/shared/components/ReceiptSubMenu.tsx b/src/shared/components/ReceiptSubMenu.tsx
deleted file mode 100644
index d86c205..0000000
--- a/src/shared/components/ReceiptSubMenu.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import { Receipt21 } from 'iconsax-react'
-import { FC } from 'react'
-import { useTranslation } from 'react-i18next'
-import SubMenuItem from './SubMenuItem'
-import { useLocation } from 'react-router-dom'
-import { Pages } from '../../config/Pages'
-
-const ReceiptSubMenu: FC = () => {
-
- const location = useLocation()
- const { t } = useTranslation('global')
-
- const isActive = (name: string) => {
- return location.pathname.includes(name)
- }
-
- return (
-
-
-
-
- {t('receip.receips')}
-
-
-
-
-
-
-
-
- )
-}
-
-export default ReceiptSubMenu
\ No newline at end of file
diff --git a/src/shared/components/ResellerSubMenu.tsx b/src/shared/components/ResellerSubMenu.tsx
new file mode 100644
index 0000000..cc75675
--- /dev/null
+++ b/src/shared/components/ResellerSubMenu.tsx
@@ -0,0 +1,43 @@
+import { UserTick } from "iconsax-react";
+import { FC } from "react";
+import { useTranslation } from "react-i18next";
+import { useLocation } from "react-router-dom";
+import { Pages } from "../../config/Pages";
+import SubMenuItem from "./SubMenuItem";
+
+const ResellerSubMenu: FC = () => {
+ const location = useLocation();
+ const { t } = useTranslation("global");
+
+ const isActive = (name: string) => location.pathname.includes(name);
+
+ return (
+
+
+
+
{t("sidebar.reseller")}
+
+
+
+
+
+
+
+ );
+};
+
+export default ResellerSubMenu;
diff --git a/src/shared/components/ServicesSubMenu.tsx b/src/shared/components/ServicesSubMenu.tsx
deleted file mode 100644
index 299717a..0000000
--- a/src/shared/components/ServicesSubMenu.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import { Element3 } from 'iconsax-react'
-import { FC } from 'react'
-import { useTranslation } from 'react-i18next'
-import SubMenuItem from './SubMenuItem'
-import { useLocation } from 'react-router-dom'
-import { Pages } from '../../config/Pages'
-
-const ServicesSubMenu: FC = () => {
-
- const location = useLocation()
- const { t } = useTranslation('global')
-
-
- const isActive = (name: string) => {
- return location.pathname.includes(name)
- }
-
- return (
-
-
-
-
- {t('sidebar.services')}
-
-
-
-
-
-
-
-
-
-
- )
-}
-
-export default ServicesSubMenu
\ No newline at end of file
diff --git a/src/shared/components/SubMenuAccordion.tsx b/src/shared/components/SubMenuAccordion.tsx
new file mode 100644
index 0000000..8509c81
--- /dev/null
+++ b/src/shared/components/SubMenuAccordion.tsx
@@ -0,0 +1,53 @@
+import { ArrowDown2 } from "iconsax-react";
+import { FC, ReactNode, useEffect, useState } from "react";
+import { clx } from "../../helpers/utils";
+import { useGetAdminPermissions } from "../../pages/users/hooks/useUserData";
+
+type Props = {
+ title: string;
+ isActive: boolean;
+ activeName?: string;
+ children: ReactNode;
+};
+
+const SubMenuAccordion: FC
= ({ title, isActive, activeName = "", children }) => {
+ const { data: adminPermissions } = useGetAdminPermissions();
+ const [open, setOpen] = useState(isActive);
+
+ useEffect(() => {
+ if (isActive) {
+ setOpen(true);
+ }
+ }, [isActive]);
+
+ if (
+ activeName !== "" &&
+ !adminPermissions?.data?.permissions?.some((permission: { name: string }) => permission.name === activeName)
+ ) {
+ return null;
+ }
+
+ return (
+
+
+ {open &&
{children}
}
+
+ );
+};
+
+export default SubMenuAccordion;
diff --git a/src/shared/components/SubMenuItem.tsx b/src/shared/components/SubMenuItem.tsx
index 59451f4..0f505a1 100644
--- a/src/shared/components/SubMenuItem.tsx
+++ b/src/shared/components/SubMenuItem.tsx
@@ -1,33 +1,38 @@
-import { FC } from 'react'
-import { Link } from 'react-router-dom'
-import { clx } from '../../helpers/utils'
+import { FC } from "react";
+import { Link } from "react-router-dom";
+import { clx } from "../../helpers/utils";
+import { useGetAdminPermissions } from "../../pages/users/hooks/useUserData";
type Props = {
- title: string,
- isActive: boolean,
- link: string,
- isLogout?: boolean,
-}
+ title: string;
+ isActive: boolean;
+ link: string;
+ isLogout?: boolean;
+ activeName?: string;
+};
const SubMenuItem: FC = (props: Props) => {
- return (
-
-
-
+ const { data: adminPermissions } = useGetAdminPermissions();
-
- )
-}
+ if (
+ props.activeName !== undefined &&
+ props.activeName !== "" &&
+ !adminPermissions?.data?.permissions?.some((permission: { name: string }) => permission.name === props.activeName)
+ ) {
+ return null;
+ }
-export default SubMenuItem
\ No newline at end of file
+ return (
+
+
+
+
+ );
+};
+
+export default SubMenuItem;
diff --git a/src/shared/components/SupportSubMenu.tsx b/src/shared/components/SupportSubMenu.tsx
deleted file mode 100644
index 9e0c9c8..0000000
--- a/src/shared/components/SupportSubMenu.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-import { Headphone } from 'iconsax-react'
-import { FC } from 'react'
-import { useTranslation } from 'react-i18next'
-import { useLocation } from 'react-router-dom'
-import { Pages } from '../../config/Pages'
-import SubMenuItem from './SubMenuItem'
-
-const SupportSubMenu: FC = () => {
-
- const location = useLocation()
- const { t } = useTranslation('global')
-
-
- const isActive = (name: string) => {
- return location.pathname.includes(name)
- }
-
-
- return
-
-
-
- {t('sidebar.support')}
-
-
-
-
-
-
-
-
-
-}
-
-export default SupportSubMenu
\ No newline at end of file
diff --git a/src/shared/components/TicketSubMenu.tsx b/src/shared/components/TicketSubMenu.tsx
deleted file mode 100644
index 6d9436d..0000000
--- a/src/shared/components/TicketSubMenu.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import { Messages3 } from 'iconsax-react'
-import { FC } from 'react'
-import { useTranslation } from 'react-i18next'
-import SubMenuItem from './SubMenuItem'
-import { useLocation } from 'react-router-dom'
-import { Pages } from '../../config/Pages'
-
-const TicketSubMenu: FC = () => {
-
- const location = useLocation()
- const { t } = useTranslation('global')
-
-
- const isActive = (name: string) => {
- return location.pathname.includes(name)
- }
-
- return (
-
-
-
-
- {t('sidebar.ticket')}
-
-
-
-
-
-
-
-
-
- )
-}
-
-export default TicketSubMenu
\ No newline at end of file
diff --git a/src/shared/components/TransactionsSubMenu.tsx b/src/shared/components/TransactionsSubMenu.tsx
deleted file mode 100644
index 20e3f23..0000000
--- a/src/shared/components/TransactionsSubMenu.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import { Card } from 'iconsax-react'
-import { FC } from 'react'
-import { useTranslation } from 'react-i18next'
-import SubMenuItem from './SubMenuItem'
-
-const TransactionsSubMenu: FC = () => {
-
- const { t } = useTranslation('global')
-
- const isActive = (name: string) => {
- return location.pathname.includes(name)
- }
-
- return (
-
-
-
-
- {t('sidebar.transactions')}
-
-
-
-
-
-
-
- )
-}
-
-export default TransactionsSubMenu
\ No newline at end of file
diff --git a/src/shared/components/UsersSubMenu.tsx b/src/shared/components/UsersSubMenu.tsx
deleted file mode 100644
index 54d1367..0000000
--- a/src/shared/components/UsersSubMenu.tsx
+++ /dev/null
@@ -1,64 +0,0 @@
-import { Profile } from 'iconsax-react'
-import { FC } from 'react'
-import { useTranslation } from 'react-i18next'
-import SubMenuItem from './SubMenuItem'
-import { Pages } from '../../config/Pages'
-
-const UsersSubMenu: FC = () => {
-
- const { t } = useTranslation('global')
-
- const isActive = (name: string) => {
- return location.pathname.includes(name)
- }
-
- return (
-
-
-
-
- {t('sidebar.users')}
-
-
-
-
-
-
-
-
-
-
-
-
- )
-}
-
-export default UsersSubMenu
\ No newline at end of file