73 lines
2.4 KiB
TypeScript
73 lines
2.4 KiB
TypeScript
'use client';
|
|
|
|
import { useRouter, usePathname } from 'next/navigation';
|
|
import { motion } from 'framer-motion';
|
|
import { FaHome, FaMusic, FaShoppingBag, FaSignOutAlt, FaChartLine } from 'react-icons/fa';
|
|
import { useAdmin } from '@/lib/AdminContext';
|
|
|
|
export default function AdminSidebar() {
|
|
const router = useRouter();
|
|
const pathname = usePathname();
|
|
const { logout } = useAdmin();
|
|
|
|
const handleLogout = () => {
|
|
logout();
|
|
router.push('/admin');
|
|
};
|
|
|
|
const menuItems = [
|
|
{ icon: FaChartLine, label: 'Dashboard', path: '/admin/dashboard' },
|
|
{ icon: FaMusic, label: 'Albums', path: '/admin/albums' },
|
|
{ icon: FaShoppingBag, label: 'Purchases', path: '/admin/purchases' },
|
|
{ icon: FaHome, label: 'Back to Site', path: '/' },
|
|
];
|
|
|
|
return (
|
|
<div className="w-64 bg-primary-900/50 backdrop-blur-sm border-r border-white/10 flex flex-col">
|
|
{/* Header */}
|
|
<div className="p-6 border-b border-white/10">
|
|
<h1 className="text-2xl font-bold text-transparent bg-clip-text bg-gradient-to-r from-accent-cyan to-accent-orange">
|
|
Admin Panel
|
|
</h1>
|
|
<p className="text-sm text-gray-400 mt-1">Parsa Music Store</p>
|
|
</div>
|
|
|
|
{/* Menu */}
|
|
<nav className="flex-1 p-4 space-y-2">
|
|
{menuItems.map((item) => {
|
|
const isActive = pathname === item.path;
|
|
const Icon = item.icon;
|
|
|
|
return (
|
|
<motion.button
|
|
key={item.path}
|
|
whileHover={{ x: 4 }}
|
|
onClick={() => router.push(item.path)}
|
|
className={`w-full flex items-center gap-3 px-4 py-3 rounded-lg transition-all ${
|
|
isActive
|
|
? 'bg-accent-cyan/20 text-accent-cyan'
|
|
: 'text-gray-300 hover:bg-white/5'
|
|
}`}
|
|
>
|
|
<Icon className="text-xl" />
|
|
<span className="font-medium">{item.label}</span>
|
|
</motion.button>
|
|
);
|
|
})}
|
|
</nav>
|
|
|
|
{/* Logout */}
|
|
<div className="p-4 border-t border-white/10">
|
|
<motion.button
|
|
whileHover={{ x: 4 }}
|
|
onClick={handleLogout}
|
|
className="w-full flex items-center gap-3 px-4 py-3 rounded-lg text-red-400 hover:bg-red-500/10 transition-all"
|
|
>
|
|
<FaSignOutAlt className="text-xl" />
|
|
<span className="font-medium">Logout</span>
|
|
</motion.button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|