diff --git a/apps/edr-freight-web/backoffice/src/new_routes/AppMenuTabs.txt b/apps/edr-freight-web/backoffice/src/new_routes/AppMenuTabs.txt new file mode 100644 index 000000000..7451e0521 --- /dev/null +++ b/apps/edr-freight-web/backoffice/src/new_routes/AppMenuTabs.txt @@ -0,0 +1,312 @@ +import { NavLink } from "react-router-dom"; +import { + Archive, + BarChart, + Building2, + ChartAreaIcon, + ClipboardList, + FileText, + Globe, + Settings, + ShieldAlert, + Users2, + UsersRound, +} from "lucide-react"; +import { useAuth } from "@/shared/context/AuthContext"; +import { usePermissions } from "@/shared/context/PermissionContext"; + +import { useTranslation } from "react-i18next"; + +export interface MenuItem { + label: string; + href: string; + icon: React.ReactNode; + roles?: string[]; + permissions?: string[]; + isPrimary?: boolean; + displayLabel?: string; + children?: MenuItem[]; +} + +export const AppMenuTabs = () => { + const { user } = useAuth(); + const userRoles = user?.roles.map((role) => role.key) || []; + + const menuItems: MenuItem[] = [ + { + label: "dashboard", + href: "/user-management/dashboard", + icon: , + roles: ["super_admin"], + isPrimary: true, + }, + { + label: "organizations", + href: "/user-management/organizations", + icon: , + roles: ["super_admin"], + isPrimary: true, + }, + + { + label: "organizationAdmins", // Shortened for mobile + displayLabel: "organizationAdmins", // Full label for desktop + href: "/user-management/organization_admins", + icon: , + roles: ["super_admin"], + isPrimary: true, + }, + { + label: "externalUsers", // Shortened for mobile + displayLabel: "externalUsers", // Full label for desktop + href: "/user-management/external_users", + icon: , + roles: ["super_admin"], + isPrimary: true, + }, + { + label: "dashboard", + href: "/user-management/user_management-dashboard", + icon: , + roles: ["admin", "organization_admin", "unit_admin"], + isPrimary: true, + }, + { + label: "userManagement", + href: "/user-management/user_management", + icon: , + roles: ["admin", "organization_admin", "unit_admin"], + isPrimary: true, + }, + // { + // label: "userPositionApproval", + // href: "/user-management/user-position-approval", + // icon: , + // roles: ["admin", "organization_admin", "unit_admin"], + // permissions: ["can:activateEmployee"], + // isPrimary: true, + // }, + // { + // label: "All Records", + // displayLabel: "All Records", + // href: "/user-management/all-records", + // icon: , + // roles: ["admin", "organization_admin", "unit_admin"], + // permissions: ["can:canViewAllRecords"], + // isPrimary: true, + // }, + { + label: "contentManagement", // Shortened for mobile + displayLabel: "contentManagement", // Full label for desktop + href: "/user-management/content-management", + icon: , + roles: ["admin", "organization_admin", "unit_admin"], + isPrimary: true, + }, + { + label: "webManagement", + displayLabel: "webManagement", + href: "/user-management/web-management", + icon: , + roles: ["admin", "organization_admin", "unit_admin"], + isPrimary: true, + }, + { + label: "Position", + displayLabel: "positionTypes", + href: "/user-management/position-management", + icon: , + roles: ["admin", "organization_admin", "unit_admin", "super_admin"], + isPrimary: true, + }, + { + label: "migratedRecords", + displayLabel: "migratedRecords", + href: "/user-management/migrated-records-management", + icon: , + roles: ["super_admin"], + isPrimary: true, + }, + { + label: "settings", + displayLabel: "settings", + href: "/user-management/organization-settings", + icon: , + roles: ["admin", "organization_admin", "unit_admin"], + isPrimary: true, + }, + { + label: "Bulk", + displayLabel: "bulkUpload", + href: "/user-management/bulk-upload", + icon: , + roles: ["admin", "organization_admin", "unit_admin"], + isPrimary: true, + }, + { + label: "Archive Users", + displayLabel: "Archive Users", + href: "/user-management/archive-users", + icon: , + roles: ["super_admin"], + isPrimary: true, + }, + { + label: "Archived Organizations", + displayLabel: "Archived Organizations", + href: "/user-management/archived-organizations", + icon: , + roles: ["super_admin"], + isPrimary: true, + }, + { + label: "Archive Users", + displayLabel: "Archive Users", + href: "/user-management/archives", + icon: , + roles: ["admin", "organization_admin", "unit_admin"], + isPrimary: true, + }, + { + label: "Archived Units & Positions", + displayLabel: "Archived Units & Positions", + href: "/user-management/archived", + icon: , + roles: ["admin", "organization_admin", "unit_admin"], + isPrimary: true, + }, + { + label: "Sector Reports", + displayLabel: "Sector Reports", + href: "/user-management/sector-reports", + icon: , + roles: ["unit_admin", "admin", "organization_admin"], + isPrimary: true, + }, + { + label: "activityLog", + href: "/user-management/activity_log", + icon: , + roles: ["super_admin"], + isPrimary: false, + }, + { + label: "setting", + href: "/user-management/settings", + icon: , + roles: ["super_admin"], + isPrimary: false, + }, + { + label: "Letter Template", + href: "/user-management/templates", + icon: , + roles: ["super_admin"], + isPrimary: false, + }, + { + label: "Add Site", + href: "/user-management/add-site", + icon: , + roles: ["super_admin"], + isPrimary: true, + }, + + // { + // label: "branding.title", + // href: "/user-management/web-management/Branding/Branding", + // icon: , + // roles: ["super_admin"], + // isPrimary: true, + // }, + ]; + + const { permissions } = usePermissions(); + const { t } = useTranslation(); + const filteredMenu = menuItems.filter((item) => + item?.roles?.some((r) => userRoles.includes(r)), + ); + const primaryMenuItems = filteredMenu.filter( + (item) => item.isPrimary !== false, + ); + const secondaryMenuItems = filteredMenu.filter( + (item) => item.isPrimary === false, + ); + + return ( +
+ {/* Mobile View - Two separate rows */} +
+ {/* Primary items row */} +
+ {primaryMenuItems.map((item) => ( + + `flex items-center gap-1 px-3 py-2.5 mr-2 text-xs font-medium transition-colors whitespace-nowrap ${ + isActive + ? "text-primary dark:text-primary-400 border-b-2 border-primary dark:border-primary-400" + : "text-slate-700 dark:text-gray-300 hover:text-primary dark:hover:text-primary-400" + }` + } + > + {item.icon} + + {t(`organization.${item.label}`, item.label)} + + + ))} +
+ + {/* Secondary items row (if any) */} + {secondaryMenuItems.length > 0 && ( +
+ {secondaryMenuItems.map((item) => ( + + `flex items-center gap-1 px-3 py-2.5 mr-2 text-xs font-medium transition-colors whitespace-nowrap ${ + isActive + ? "text-primary dark:text-primary-400 border-b-2 border-primary dark:border-primary-400" + : "text-slate-700 dark:text-gray-300 hover:text-primary dark:hover:text-primary-400" + }` + } + > + {item.icon} + + {t(`organization.${item.label}`, item.label)} + + + ))} +
+ )} +
+ + {/* Desktop View - Single row with all items */} +
+
+ {filteredMenu.map((item) => ( + + `flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors whitespace-nowrap ${ + isActive + ? "text-primary dark:text-primary-400 border-b-2 border-primary dark:border-primary-400" + : "text-slate-700 dark:text-gray-300 hover:text-primary dark:hover:text-primary-400" + }` + } + > + {item.icon} + + {t(`organization.${item.label}`, item.label)} + + + ))} +
+
+
+ ); +}; diff --git a/apps/edr-freight-web/backoffice/src/new_routes/Applayout.txt b/apps/edr-freight-web/backoffice/src/new_routes/Applayout.txt new file mode 100644 index 000000000..0e9d7a52e --- /dev/null +++ b/apps/edr-freight-web/backoffice/src/new_routes/Applayout.txt @@ -0,0 +1,36 @@ +import { useLocation } from "react-router-dom"; +import { Outlet } from "react-router-dom"; +import { AppMenuTabs } from "./AppMenuTabs"; +import { useSidebar } from "@/shared/common/ui/sidebar"; +import Top from "@/record-management/components/common/Top"; +import { useAuth } from "@/shared/context/AuthContext"; + +export const AppLayout = () => { + const { pathname } = useLocation(); + const isAuthPage = pathname === "/"; + const { toggleSidebar } = useSidebar(); + const { user } = useAuth(); + + const userRoles = user?.roles?.map((role) => role.key) || []; + const isSuperAdmin = userRoles.includes("super_admin"); + + if (isAuthPage) { + return ( +
+ +
+ ); + } + + return ( +
+ + +
+
+ +
+
+
+ ); +}; diff --git a/apps/edr-freight-web/backoffice/src/new_routes/route.txt b/apps/edr-freight-web/backoffice/src/new_routes/route.txt new file mode 100644 index 000000000..1853de26e --- /dev/null +++ b/apps/edr-freight-web/backoffice/src/new_routes/route.txt @@ -0,0 +1,197 @@ + }> + + + + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + + {/* Super Admin */} + + } + > + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + + + {/* Org Admin */} + + } + > + } + /> + } + /> + } + // > + + // + } + /> + } + > + + + } + /> + } + > + + + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + + \ No newline at end of file