'use client';

import DashboardLayout from '@/components/layout/DashboardLayout';
import {
  LayoutDashboard, Users, Package, ShoppingBag, Send,
  Settings, FileText, ShieldAlert, Landmark, Store, ShieldCheck, Share2
} from 'lucide-react';
import Link from 'next/link';
import { MessageCircle } from 'lucide-react';
import { useParams } from 'next/navigation';

const adminMenuGroups = [
  {
    title: 'HỆ THỐNG',
    items: [
      { href: '/admin', label: 'Dashboard', icon: LayoutDashboard, exact: true },
      { href: '/admin/users', label: 'Quản lý Users', icon: Users },
      { href: '/admin/products', label: 'Quản lý Sản phẩm', icon: Package },
      { href: '/admin/orders', label: 'Quản lý Đơn hàng', icon: ShoppingBag },
      { href: '/admin/payments', label: 'Quản lý Nạp tiền', icon: ShieldCheck },
      { href: '/admin/withdrawals', label: 'Quản lý Rút tiền', icon: Landmark },
      { href: '/admin/disputes', label: 'Quản lý Khiếu nại', icon: ShieldAlert },
      { href: '/admin/seller-applications', label: 'Đơn xin làm Seller', icon: Store },
      { href: '/admin/chat-center', label: 'Chat Center', icon: MessageCircle },
      { href: '/admin/affiliate', label: 'Quản lý Affiliate', icon: Share2 },
      { href: '/admin/telegram', label: 'Quản lý Telegram Bot', icon: Send },
    ]
  },
  {
    title: 'CẤU HÌNH',
    items: [
      { href: '/admin/cms', label: 'Quản lý CMS', icon: FileText },
      { href: '/admin/settings', label: 'Cấu hình hệ thống', icon: Settings },
    ]
  }
];

export default function AdminLayout({ children }: { children: React.ReactNode }) {
  const params = useParams();
  const locale = (params?.locale as string) || 'vi';
  const headerLogo = (
    <Link href={`/${locale}/admin`} className="flex items-center gap-2 font-black text-xl tracking-tighter">
      <ShieldAlert className="w-5 h-5 text-red-500" />
      <span className="text-white">SUPER</span>
      <span className="text-red-500">ADMIN</span>
    </Link>
  );

  return (
    <DashboardLayout
      menuGroups={adminMenuGroups}
      headerLogo={headerLogo}
      requireRole={['ADMIN', 'SUPER_ADMIN']}
    >
      {children}
    </DashboardLayout>
  );
}
