"use client"; import React, { Dispatch, SetStateAction, useState, useEffect } from "react"; import Image from "next/image"; import { Icon } from "@iconify/react"; import Link from "next/link"; import DashboardContainer from "../main/dashboard/dashboard-container"; import { usePathname, useRouter } from "next/navigation"; import { motion, AnimatePresence } from "framer-motion"; import { useTheme } from "../layout/theme-context"; import Option from "./option"; import { LogOut } from "lucide-react"; import withReactContent from "sweetalert2-react-content"; import Swal from "sweetalert2"; import Cookies from "js-cookie"; interface RetractingSidebarProps { sidebarData: boolean; updateSidebarData: (newData: boolean) => void; } const sidebarSections = [ // { // title: "Dashboard", // items: [ // { // title: "Dashboard", // icon: () => ( // // ), // link: "/admin/dashboard", // }, // ], // }, { title: "Dashboard", items: [ { title: "Dashboard", icon: () => ( ), link: "/admin/dashboard", }, { title: "Banner", icon: () => , link: "/admin/banner", }, { title: "Produk", icon: () => , link: "/admin/product", }, // { // title: "Majalah", // icon: () => , // link: "/admin/magazine", // }, { title: "Agent", icon: () => , link: "/admin/agent", }, { title: "Promo", icon: () => , link: "/admin/promotion", }, { title: "Galeri", icon: () => , link: "/admin/galery", }, { title: "Services", icon: () => , link: "/admin/services", }, { title: "Layanan Konsumen", icon: () => ( ), link: "/admin/costumer-service", }, { title: "Manajemen User", icon: () => , link: "/admin/master-user", }, ], }, ]; export const RetractingSidebar = ({ sidebarData, updateSidebarData, }: RetractingSidebarProps) => { const pathname = usePathname(); const [mounted, setMounted] = useState(false); useEffect(() => { setMounted(true); }, []); if (!mounted) { return null; } return ( <> {/* DESKTOP SIDEBAR */} {/* Desktop Toggle Button - appears when sidebar is collapsed */} {!sidebarData && ( updateSidebarData(true)} > )} {!sidebarData && ( updateSidebarData(true)} > )} {sidebarData && ( {/* updateSidebarData(false)} className="mb-4 self-end text-zinc-500"> ✕ */} )} > ); }; const SidebarContent = ({ open, pathname, updateSidebarData, }: { open: boolean; pathname: string; updateSidebarData: (newData: boolean) => void; }) => { const roleLabel: Record = { 1: "Admin", 2: "Operator", }; const [userRoleId, setUserRoleId] = useState(null); useEffect(() => { const urie = Cookies.get("urie"); setUserRoleId(urie ? Number(urie) : null); }, []); const { theme, toggleTheme } = useTheme(); return ( {/* */} {open && ( JAECOO{" "} {/* {userRoleId != null ? roleLabel[userRoleId] : ""} */} {/* Admin Panel */} )} {open && ( updateSidebarData(false)} > )} {sidebarSections.map((section, sectionIndex) => ( {open && ( {section.title} )} {section.items.map((item, itemIndex) => ( ))} ))} {theme === "dark" ? ( ) : ( )} {open && ( {theme === "dark" ? "Light Mode" : "Dark Mode"} )} ( )} title="Settings" active={pathname === "/settings"} open={open} /> {/* A */} {open && ( {/* Jaecoo */} Log Out )} {/* Expand Button for Collapsed State */} {/* {!open && ( updateSidebarData(true)} className="w-full p-3 rounded-xl bg-gradient-to-r from-blue-500 to-purple-500 hover:from-blue-600 hover:to-purple-600 text-white shadow-lg transition-all duration-200 hover:shadow-xl group" > )} */} ); }; const Sidebar = () => { const [open, setOpen] = useState(true); const pathname = usePathname(); return ( {!open && ( setOpen(true)} > )} {open && ( setOpen(false)} > )} {sidebarSections.map((section) => ( {section.title} {section.items.map((item) => ( ))} ))} {/* BAGIAN BAWAH */} } title="Theme" active={false} open={open} /> ( )} title="Settings" active={pathname === "/settings"} open={open} /> {" "} {/* admin-mabes */} Logout ); }; export default Sidebar; const TitleSection = ({ open }: { open: boolean }) => { return ( {/* {open && } */} ); }; const ToggleClose = ({ open, setOpen, }: { open: boolean; setOpen: Dispatch>; }) => { return ( setOpen((pv) => !pv)}> {/* */} {/* {open && ( Hide )} */} ); }; const ExampleContent = () => ( );
JAECOO{" "} {/* {userRoleId != null ? roleLabel[userRoleId] : ""} */}
Jaecoo
Log Out
{section.title}
admin-mabes
Logout