import { SidebarMenuTask } from "@/types/globals"; import { Tooltip } from "@nextui-org/react"; import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import React, { useEffect, useState } from "react"; import { ChevronLeftIcon, ChevronRightIcon, FormCustomIcon, FormHorizontalIcon, FormLayoutIcon, FormValidationIcon, FormVerticalIcon, } from "../../icons"; import { ArticleIcon, DashboardIcon, HomeIcon, InfoCircleIcon, MagazineIcon, MasterCategoryIcon, MasterRoleIcon, MasterUsersIcon, MinusCircleIcon, StaticPageIcon, TableIcon, } from "../../icons/sidebar-icon"; import { ThemeSwitch } from "../../theme-switch"; import { SidebarCollapseItems } from "./sidebar-collapse-items"; import { SidebarCollapseSubItems } from "./sidebar-collapse-sub-items"; import { useSidebar } from "./sidebar-context"; import { SidebarMenu } from "./sidebar-menu"; import Image from "next/image"; import Cookies from "js-cookie"; import { SettingsIcon, UserProfileIcon } from "@/components/icons/globals"; interface SubMenuItems { id: number; name: string; modulePathUrl: string; isSubActive: boolean; } interface MenuItems { id: number; name: string; modulePathUrl: string; isSubActive: boolean; childMenu?: SubMenuItems[]; icon?: string; } interface SidebarProps { sidebarData: boolean; updateSidebarData: (newData: boolean) => void; } const sideBarDummyData = [ { id: 1, name: "Dashboard", moduleId: 652, moduleName: "Dashboard", modulePathUrl: "/admin/dashboard", isGroup: true, parentId: -1, icon: "dashboard", position: 1, statusId: 1, childMenu: [], statusName: "Active", childModule: null, }, { id: 2, name: "Dashboard", moduleId: 652, moduleName: "Dashboard", modulePathUrl: "/admin/dashboard", parentId: -1, icon: , position: 1, statusId: 1, childMenu: [], statusName: "Active", childModule: null, }, { id: 3, name: "Apps", moduleId: 652, moduleName: "Dashboard", modulePathUrl: "/admin/basic", isGroup: true, parentId: -1, icon: "table", position: 1, statusId: 1, childMenu: [], statusName: "Active", childModule: null, }, { id: 4, name: "Artikel", moduleId: 652, moduleName: "Dashboard", modulePathUrl: "/admin/article", parentId: -1, icon: , position: 1, statusId: 1, childMenu: [], statusName: "Active", childModule: null, }, { id: 30, name: "Kategori", moduleId: 654, moduleName: "Master", modulePathUrl: "/admin/master-category", parentId: -1, icon: , position: 1, statusId: 1, childMenu: [], statusName: "Active", childModule: null, }, { id: 6, name: "Majalah", moduleId: 652, moduleName: "Apps", modulePathUrl: "/admin/magazine", parentId: -1, icon: , position: 1, statusId: 1, childMenu: [], statusName: "Active", childModule: null, }, // { // id: 4, // name: "E-Magazine", // moduleId: 652, // moduleName: "Dashboard", // modulePathUrl: "/admin/e-magazine", // parentId: -1, // icon: , // position: 1, // statusId: 1, // childMenu: [], // statusName: "Active", // childModule: null, // }, { id: 5, name: "Master", moduleId: 652, moduleName: "Dashboard", isGroup: true, modulePathUrl: "/admin/basic", parentId: -1, icon: "table", position: 1, statusId: 1, childMenu: [], statusName: "Active", childModule: null, }, // { // id: 6, // name: "Master Menu", // moduleId: 652, // moduleName: "Form Custom", // modulePathUrl: "/admin/master-menu", // parentId: -1, // icon: , // position: 1, // statusId: 1, // childMenu: [], // statusName: "Active", // childModule: null, // }, // { // id: 7, // name: "Master Module", // moduleId: 653, // moduleName: "Form Horizontal", // modulePathUrl: "/admin/master-module", // parentId: -1, // icon: , // position: 1, // statusId: 1, // childMenu: [], // statusName: "Active", // childModule: null, // }, { id: 11, name: "Master Static Page", moduleId: 652, moduleName: "Dashboard", modulePathUrl: "/admin/static-page", parentId: -1, icon: , position: 1, statusId: 1, childMenu: [], statusName: "Active", childModule: null, }, { id: 8, name: "Master User", moduleId: 654, moduleName: "Form Vertical", modulePathUrl: "/admin/master-user", parentId: -1, icon: , position: 1, statusId: 1, childMenu: [], statusName: "Active", childModule: null, }, { id: 10, name: "Master User Role", moduleId: 656, moduleName: "Form Validation", modulePathUrl: "/admin/master-role", parentId: -1, icon: , position: 1, statusId: 1, childMenu: [], statusName: "Active", childModule: null, }, ]; const SidebarMobile: React.FC = ({ updateSidebarData }) => { const pathname = usePathname(); const router = useRouter(); const [sidebarMenu, setSidebarMenu] = useState(); const { isOpen, toggleSidebar } = useSidebar(); const token = Cookies.get("access_token"); const username = Cookies.get("username"); const isAuthenticated = Cookies.get("is_authenticated"); useEffect(() => { if (!token) { onLogout(); } }, [token]); const onLogout = () => { Object.keys(Cookies.get()).forEach((cookieName) => { Cookies.remove(cookieName); }); router.push("/auth"); }; useEffect(() => { updateSidebarData(isOpen); }, [isOpen]); return ( {!isOpen && ( )} {/* {isOpen && ACME} */} {isOpen && ( )} {sideBarDummyData ? sideBarDummyData?.map((list: any, index: number) => list.isGroup ? ( {isOpen ? list.name : "..."} ) : list.childMenu?.length < 1 ? ( isOpen ? ( {/* */} {list.icon} {isOpen && list.name} ) : ( {list.icon} {isOpen && list.name} ) ) : ( ( )), ]} /> ) ) : ""} {isOpen && "Theme"} {isOpen ? ( {isOpen && "Settings"} ) : ( {isOpen && "Settings"} )} {isOpen ? ( {username} onLogout()} > Logout ) : ( )} ); }; export default SidebarMobile;
{isOpen ? list.name : "..."}