diff --git a/src/config/SideBarSubMenu.ts b/src/config/SideBarSubMenu.ts index c09def2..2ded6d1 100644 --- a/src/config/SideBarSubMenu.ts +++ b/src/config/SideBarSubMenu.ts @@ -1,57 +1,46 @@ export const SideBarItemHasSubMenu = [ - "menu", - "financial", - "other", + "services", + "customers", + "representatives", + "users", "content", - "reseller", - "dmenu", - "dkala", - "dpage", - "dmail", + "financial", + "support", + "other", + "products", ]; const pathSegmentToSubMenu: Record = { - dashboard: "menu", - services: "menu", - support: "menu", - customers: "menu", - representatives: "menu", - developers: "menu", - payments: "menu", - "referral-code": "menu", - users: "menu", - sliders: "menu", - subscriptions: "financial", - receipts: "financial", - transactions: "financial", - discounts: "financial", - "card-bank": "financial", - tickets: "other", - feedback: "other", - "access-logs": "other", - criticisms: "other", - workspace: "other", - project: "other", - taskmanager: "other", + services: "services", + customers: "customers", + representatives: "representatives", + reseller: "representatives", + users: "users", ads: "content", announcement: "content", blog: "content", learning: "content", - messages: "content", - reseller: "reseller", - dmenu: "dmenu", - dkala: "dkala", - dpage: "dpage", - dmail: "dmail", + sliders: "content", + payments: "financial", + receipts: "financial", + transactions: "financial", + discounts: "financial", + "card-bank": "financial", + support: "support", + tickets: "support", + feedback: "other", + "access-logs": "other", + criticisms: "other", + messages: "other", + dmenu: "products", + dkala: "products", + dpage: "products", + dmail: "products", }; export const getSubMenuNameFromPath = (pathname: string): string => { if (pathname.startsWith("/customers/subscriptions")) { - return "financial"; - } - - if (pathname.startsWith("/workspace") || pathname.startsWith("/project") || pathname.startsWith("/taskmanager")) { - return "other"; + return "customers"; } const segment = pathname.split("/")[1] ?? ""; diff --git a/src/langs/fa.json b/src/langs/fa.json index f9bbb7f..3f438bf 100644 --- a/src/langs/fa.json +++ b/src/langs/fa.json @@ -59,7 +59,7 @@ "mainpage": "صفحه اصلی", "myservice": "سرویس های من", "other_service": "سایر سرویس ها", - "receipt_list": "لیست صورتحساب", + "receipt_list": "صورتحساب ها", "transactions": "تراکنش ها", "other": "سایر", "ticket": "تیکت ها", @@ -72,8 +72,9 @@ "payments": "پرداخت ها", "sliders": "اسلایدر", "support": "پلن پشتیبانی", + "support_section": "پشتیبانی", "feedback": "گزارش ها", - "accessLogs": "لاگ‌های دسترسی", + "accessLogs": "لگ دسترسی", "icons": "آیکون ها", "dmenu": "دی منو", "dkala": "دی کالا", @@ -86,6 +87,7 @@ "sms_count": "تعداد پیامک", "subscriptions": "اشتراک ها", "financial": "مالی", + "products": "محصولات", "dmail": "دی میل", "domain": "دامنه", "reseller": "نماینده", @@ -129,7 +131,9 @@ "service_category": "دسته بندی سرویس ها", "customer_list": "لیست مشتریان", "create_customer": "افزودن مشتری", + "representative_list": "لیست نمایندگان", "ticket_list": "لیست تیکت ها", + "ticket_category": "دسته بندی تیکت ها", "send_ticket": "ارسال تیکت", "category": "دسته بندی", "user_list": "لیست کاربران", @@ -141,9 +145,15 @@ "plan_users": "کاربران پلن", "plan_list": "لیست پلن ها", "guide": "راهنمای سرویس", + "blog_list": "لیست بلاگ", + "blog_comments": "نظرات بلاگ", + "blog_category": "دسته بندی بلاگ", + "learning_list": "لیست آموزش ها", + "learning_category": "دسته بندی آموزش ها", "access_logs_list": "لیست لاگ‌ها", "access_logs_stats": "آمار لاگ‌ها", "access_logs_errors": "لاگ‌های خطا", + "access_logs_permissions": "لاگ‌های مجوز", "taskmanager_workspace": "فضای کاری", "taskmanager_workspace_list": "لیست فضاهای کاری", "taskmanager_create_workspace": "ساخت فضای کاری جدید", diff --git a/src/shared/SideBar.tsx b/src/shared/SideBar.tsx index c2021db..a4885b0 100644 --- a/src/shared/SideBar.tsx +++ b/src/shared/SideBar.tsx @@ -1,13 +1,15 @@ import { - Building, + Box, Category, DocumentLike, Element3, - Gallery, - Global, + Headphone, Logout, Money3, + Profile, + Profile2User, Setting2, + UserOctagon, UserTick, } from "iconsax-react"; import { FC, useEffect } from "react"; @@ -21,14 +23,14 @@ import { clx } from "../helpers/utils"; import { useGetProfile } from "../pages/profile/hooks/useProfileData"; import { useGetAdminPermissions } from "../pages/users/hooks/useUserData"; import ContentSubMenu from "./components/ContentSubMenu"; -import DkalaSubMenu from "./components/DkalaSubMenu"; -import DmailSubMenu from "./components/DmailSubMenu"; -import DmenuSubMenu from "./components/DmenuSubMenu"; -import DpageSubMenu from "./components/DpageSubMenu"; +import CustomersSubMenu from "./components/CustomersSubMenu"; import FinancialSubMenu from "./components/FinancialSubMenu"; -import MenuSubMenu from "./components/MenuSubMenu"; import OtherSubMenu from "./components/OtherSubMenu"; +import ProductsSubMenu from "./components/ProductsSubMenu"; import ResellerSubMenu from "./components/ResellerSubMenu"; +import ServicesSubMenu from "./components/ServicesSubMenu"; +import SupportSubMenu from "./components/SupportSubMenu"; +import UsersSubMenu from "./components/UsersSubMenu"; import SideBarItem from "./SideBarItem"; import { useSharedStore } from "./store/sharedStore"; @@ -40,6 +42,20 @@ const SideBar: FC = () => { const { data: adminPermissions } = useGetAdminPermissions(); const isGroupActive = (name: string) => subMenuName === name || getSubMenuNameFromPath(location.pathname) === name; + const isPathActive = (name: string) => location.pathname.includes(name); + + const hasProductPermission = adminPermissions?.data?.permissions?.some((permission: { name: string }) => + ["dmenu", "dkala", "dpage", "dmail"].includes(permission.name), + ); + + const productsDefaultLink = (() => { + const permissions = adminPermissions?.data?.permissions?.map((p: { name: string }) => p.name) ?? []; + if (permissions.includes("dmenu")) return Pages.dmenu.icons.list; + if (permissions.includes("dkala")) return Pages.dkala.icons.list; + if (permissions.includes("dmail")) return Pages.dmail.list; + if (permissions.includes("dpage")) return Pages.dpage.stickers.list; + return Pages.dashboard; + })(); useEffect(() => { const groupName = getSubMenuNameFromPath(location.pathname); @@ -91,15 +107,105 @@ const SideBar: FC = () => { } - title={t("sidebar.menu")} - isActive={isGroupActive("menu")} + title={t("sidebar.mainpage")} + isActive={isPathActive("dashboard")} link={Pages.dashboard} - name="menu" + activeName="" + /> + + + } + title={t("sidebar.services")} + isActive={isGroupActive("services")} + link={Pages.services.list} + name="services" + activeName="services" + /> + + + } + title={t("sidebar.customers")} + isActive={isGroupActive("customers")} + link={Pages.customer.list} + name="customers" + activeName="customers" + /> + + {adminPermissions?.data?.permissions?.some((permission: { name: string }) => permission.name === "reseller") && ( + + } + title={t("sidebar.representatives")} + isActive={isGroupActive("representatives")} + link={Pages.reseller.list} + name="representatives" + activeName="reseller" + /> + )} + + + } + title={t("sidebar.developers")} + isActive={isPathActive("developers")} + link={Pages.developers.list} + activeName="developers" + /> + + + } + title={t("sidebar.users")} + isActive={isGroupActive("users")} + link={Pages.users.list} + name="users" + activeName="admins" + /> + + + } + title={t("sidebar.mnage_content")} + isActive={isGroupActive("content")} + link={Pages.blog.list} + name="content" activeName="" /> @@ -113,11 +219,26 @@ const SideBar: FC = () => { } title={t("sidebar.financial")} isActive={isGroupActive("financial")} - link={Pages.receipts.index} + link={Pages.payment.list} name="financial" activeName="" /> + + } + title={t("sidebar.support_section")} + isActive={isGroupActive("support")} + link={Pages.support.list} + name="support" + activeName="" + /> + {profile?.data?.user?.roles?.some((role: { name: string }) => role.name === "super_admin") && ( { } title={t("sidebar.other")} isActive={isGroupActive("other")} - link={Pages.ticket.list} + link={Pages.feedback.list} name="other" activeName="" /> )} - - } - title={t("sidebar.mnage_content")} - isActive={isGroupActive("content")} - link={Pages.ads.list} - name="content" - activeName="" - /> - - {adminPermissions?.data?.permissions?.some((permission: { name: string }) => permission.name === "reseller") && ( + {hasProductPermission && ( } - title={t("sidebar.reseller")} - isActive={isGroupActive("reseller")} - link={Pages.reseller.list} - name="reseller" - activeName="reseller" - /> - )} - - {adminPermissions?.data?.permissions?.some((permission: { name: string }) => permission.name === "dmenu") && ( - - } - title={t("sidebar.dmenu")} - isActive={isGroupActive("dmenu")} - link={Pages.dmenu.icons.list} - name="dmenu" - activeName="dmenu" - /> - )} - - {adminPermissions?.data?.permissions?.some((permission: { name: string }) => permission.name === "dkala") && ( - - } - title={t("sidebar.dkala")} - isActive={isGroupActive("dkala")} - link={Pages.dkala.icons.list} - name="dkala" - activeName="dkala" - /> - )} - - {adminPermissions?.data?.permissions?.some((permission: { name: string }) => permission.name === "dpage") && ( - - } - title={t("sidebar.dpage")} - isActive={isGroupActive("dpage")} - link={Pages.dpage.stickers.list} - name="dpage" - activeName="dpage" - /> - )} - - {adminPermissions?.data?.permissions?.some((permission: { name: string }) => permission.name === "dmail") && ( - - } - title={t("sidebar.dmail")} - isActive={isGroupActive("dmail")} - link={Pages.dmail.list} - name="dmail" - activeName="dmail" + title={t("sidebar.products")} + isActive={isGroupActive("products")} + link={productsDefaultLink} + name="products" + activeName="" /> )} @@ -274,24 +312,24 @@ const SideBar: FC = () => { {hasSubMenu && (openSidebar || window.innerWidth > 1139) && (
- {subMenuName === "menu" ? ( - - ) : subMenuName === "financial" ? ( - - ) : subMenuName === "other" ? ( - + {subMenuName === "services" ? ( + + ) : subMenuName === "customers" ? ( + + ) : subMenuName === "representatives" ? ( + + ) : subMenuName === "users" ? ( + ) : subMenuName === "content" ? ( - ) : subMenuName === "reseller" ? ( - - ) : subMenuName === "dmenu" ? ( - - ) : subMenuName === "dkala" ? ( - - ) : subMenuName === "dpage" ? ( - - ) : subMenuName === "dmail" ? ( - + ) : subMenuName === "financial" ? ( + + ) : subMenuName === "support" ? ( + + ) : subMenuName === "other" ? ( + + ) : subMenuName === "products" ? ( + ) : null}
)} diff --git a/src/shared/components/ContentSubMenu.tsx b/src/shared/components/ContentSubMenu.tsx index c6d218d..3b8fcd7 100644 --- a/src/shared/components/ContentSubMenu.tsx +++ b/src/shared/components/ContentSubMenu.tsx @@ -3,7 +3,6 @@ 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 = () => { @@ -24,68 +23,53 @@ const ContentSubMenu: FC = () => {
+ + + + + - - - - - - - - - - - - -
diff --git a/src/shared/components/DmailSubMenu.tsx b/src/shared/components/CustomersSubMenu.tsx similarity index 54% rename from src/shared/components/DmailSubMenu.tsx rename to src/shared/components/CustomersSubMenu.tsx index a231ea0..8f6b5a1 100644 --- a/src/shared/components/DmailSubMenu.tsx +++ b/src/shared/components/CustomersSubMenu.tsx @@ -1,11 +1,11 @@ -import { Global } from "iconsax-react"; +import { Profile2User } 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 CustomersSubMenu: FC = () => { const location = useLocation(); const { t } = useTranslation("global"); @@ -14,24 +14,30 @@ const DmailSubMenu: FC = () => { return (
- -
{t("sidebar.dmail")}
+
{t("sidebar.customers")}
+
); }; -export default DmailSubMenu; +export default CustomersSubMenu; diff --git a/src/shared/components/DkalaSubMenu.tsx b/src/shared/components/DkalaSubMenu.tsx deleted file mode 100644 index 2722120..0000000 --- a/src/shared/components/DkalaSubMenu.tsx +++ /dev/null @@ -1,61 +0,0 @@ -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/DmenuSubMenu.tsx b/src/shared/components/DmenuSubMenu.tsx deleted file mode 100644 index 743f6df..0000000 --- a/src/shared/components/DmenuSubMenu.tsx +++ /dev/null @@ -1,61 +0,0 @@ -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 deleted file mode 100644 index 26d20c5..0000000 --- a/src/shared/components/DpageSubMenu.tsx +++ /dev/null @@ -1,37 +0,0 @@ -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 index 8714ae7..71c50fa 100644 --- a/src/shared/components/FinancialSubMenu.tsx +++ b/src/shared/components/FinancialSubMenu.tsx @@ -3,7 +3,6 @@ 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 = () => { @@ -25,29 +24,17 @@ const FinancialSubMenu: 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 index 1cb69cf..e8d891c 100644 --- a/src/shared/components/OtherSubMenu.tsx +++ b/src/shared/components/OtherSubMenu.tsx @@ -12,15 +12,6 @@ const OtherSubMenu: FC = () => { 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 (
@@ -33,28 +24,6 @@ const OtherSubMenu: FC = () => {
- - - - - - { link={Pages.accessLogs.errors} /> @@ -96,9 +65,10 @@ const OtherSubMenu: FC = () => { activeName="criticisms" />
diff --git a/src/shared/components/ProductsSubMenu.tsx b/src/shared/components/ProductsSubMenu.tsx new file mode 100644 index 0000000..852d8e2 --- /dev/null +++ b/src/shared/components/ProductsSubMenu.tsx @@ -0,0 +1,131 @@ +import { Box } 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 ProductsSubMenu: FC = () => { + const location = useLocation(); + const { t } = useTranslation("global"); + + const isActive = (name: string) => location.pathname.includes(name); + + return ( +
+
+ +
{t("sidebar.products")}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
+
+ ); +}; + +export default ProductsSubMenu; diff --git a/src/shared/components/ResellerSubMenu.tsx b/src/shared/components/ResellerSubMenu.tsx index cc75675..ba600af 100644 --- a/src/shared/components/ResellerSubMenu.tsx +++ b/src/shared/components/ResellerSubMenu.tsx @@ -19,13 +19,13 @@ const ResellerSubMenu: FC = () => { color="#000" variant="Bold" /> -
{t("sidebar.reseller")}
+
{t("sidebar.representatives")}
diff --git a/src/shared/components/ServicesSubMenu.tsx b/src/shared/components/ServicesSubMenu.tsx new file mode 100644 index 0000000..8d07a00 --- /dev/null +++ b/src/shared/components/ServicesSubMenu.tsx @@ -0,0 +1,49 @@ +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 SubMenuItem from "./SubMenuItem"; + +const ServicesSubMenu: FC = () => { + const location = useLocation(); + const { t } = useTranslation("global"); + + const isActive = (name: string) => location.pathname.includes(name); + + return ( +
+
+ +
{t("sidebar.services")}
+
+ +
+ + + +
+
+ ); +}; + +export default ServicesSubMenu; diff --git a/src/shared/components/SupportSubMenu.tsx b/src/shared/components/SupportSubMenu.tsx new file mode 100644 index 0000000..1d4f466 --- /dev/null +++ b/src/shared/components/SupportSubMenu.tsx @@ -0,0 +1,49 @@ +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) => location.pathname.includes(name); + + return ( +
+
+ +
{t("sidebar.support_section")}
+
+ +
+ + + +
+
+ ); +}; + +export default SupportSubMenu; diff --git a/src/shared/components/UsersSubMenu.tsx b/src/shared/components/UsersSubMenu.tsx new file mode 100644 index 0000000..05eddab --- /dev/null +++ b/src/shared/components/UsersSubMenu.tsx @@ -0,0 +1,49 @@ +import { Profile } 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 UsersSubMenu: FC = () => { + const location = useLocation(); + const { t } = useTranslation("global"); + + const isActive = (name: string) => location.pathname.includes(name); + + return ( +
+
+ +
{t("sidebar.users")}
+
+ +
+ + + +
+
+ ); +}; + +export default UsersSubMenu;