"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 } from "next/navigation"; import { motion, AnimatePresence } from "framer-motion"; import { useTheme } from "../layout/theme-context"; import Option from "./option"; interface RetractingSidebarProps { sidebarData: boolean; updateSidebarData: (newData: boolean) => void; } const sidebarSections = [ { title: "Dashboard", items: [ { title: "Dashboard", icon: () => ( ), link: "/admin/dashboard", }, ], }, { title: "Content Management", items: [ { title: "Articles", icon: () => , link: "/admin/article", }, { title: "Categories", icon: () => , link: "/admin/master-category", }, // { // title: "Majalah", // icon: () => , // link: "/admin/magazine", // }, { title: "Advertisements", icon: () => , link: "/admin/advertise", }, // { // title: "Komentar", // icon: () => , // link: "/admin/komentar", // }, ], }, { title: "System", items: [ { title: "Static Pages", icon: () => , link: "/admin/static-page", }, { title: "User Management", 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)} > )} {/* Mobile Toggle Button */} {!sidebarData && ( updateSidebarData(true)} > )} {/* MOBILE SIDEBAR */} {sidebarData && ( {/* */} )} ); }; const SidebarContent = ({ open, pathname, updateSidebarData, }: { open: boolean; pathname: string; updateSidebarData: (newData: boolean) => void; }) => { const { theme, toggleTheme } = useTheme(); const [username, setUsername] = useState(""); useEffect(() => { // Ambil cookie secara client-side const cookies = document.cookie.split("; ").reduce((acc: any, cur) => { const [key, value] = cur.split("="); acc[key] = value; return acc; }, {}); setUsername(cookies.username || "Guest"); }, []); return (
{/* SCROLLABLE TOP SECTION */}
{/* HEADER SECTION */}
{/* Logo and Toggle */}
{open && ( Isu kini Admin Panel )} {open && ( updateSidebarData(false)} > )}
{/* Navigation Sections */}
{sidebarSections.map((section, sectionIndex) => ( {open && ( {section.title} )}
{section.items.map((item, itemIndex) => (
))}
{/* FIXED BOTTOM SECTION */}
{/* Divider */} {/*
*/} {/* Theme Toggle */}
{theme === "dark" ? ( ) : ( )}
{open && ( {theme === "dark" ? "Light Mode" : "Dark Mode"} )}
{/* Settings */}
{/* User Profile */}
A
{open && (

{username}

Sign out

)}
{/* Expand Button for Collapsed State */} {/* {!open && ( )} */}
); }; const Sidebar = () => { const [open, setOpen] = useState(true); const pathname = usePathname(); const [username, setUsername] = useState(""); useEffect(() => { // Ambil cookie secara client-side const cookies = document.cookie.split("; ").reduce((acc: any, cur) => { const [key, value] = cur.split("="); acc[key] = value; return acc; }, {}); setUsername(cookies.username || "Guest"); }, []); return ( {/* BAGIAN ATAS */}
{!open && (
)}
{open && ( )}
{sidebarSections.map((section) => (

{section.title}

{section.items.map((item) => (
))}
{/* BAGIAN BAWAH */}
); }; export default Sidebar; const TitleSection = ({ open }: { open: boolean }) => { return (
logo
{/* {open && } */}
); }; const ToggleClose = ({ open, setOpen, }: { open: boolean; setOpen: Dispatch>; }) => { return ( setOpen((pv) => !pv)}>
{/* */} {/* {open && ( Hide )} */}
); }; const ExampleContent = () => (
);