/**
 * Sales Admin Layout
 * Navigation wrapper for all sales routes
 */

import { ReactNode } from 'react';
import DashboardLayout from '@/components/layout/dashboard-layout';
import SalesLayoutShell from '@/components/admin/sales-layout-shell';
import { getCurrentLocale } from '@/lib/i18n';

interface SalesLayoutProps {
  children: ReactNode;
}

export const metadata = {
  title: 'Sales Management',
  description: 'Manage sales invoices, payments, and customer accounts',
};

export default async function SalesLayout({ children }: SalesLayoutProps) {
  const locale = await getCurrentLocale();
  const isRtl = locale === 'ar';

  // Navigation items for sales module
  const navItems = [
    {
      title: 'الفواتير',
      href: '/admin/sales',
      subLinks: [
        { title: 'إنشاء فاتورة', href: '/admin/sales' },
        { title: 'الفواتير السابقة', href: '/admin/sales/history' },
        { title: 'تقرير ذمم التغطية', href: '/admin/sales/coverage-report' },
      ],
    },
    {
      title: 'الدفعات',
      href: '/admin/sales/payment/received',
    },
    {
      title: 'مردودات المبيعات',
      href: '/admin/sales/returns',
      subLinks: [
        { title: 'تسجيل مردود', href: '/admin/sales/returns' },
        { title: 'قائمة فواتير مردود المبيعات', href: '/admin/sales/returns/list' },
      ],
    },
    {
      title: 'إذونات التخفيض',
      href: '/admin/sales/debit-notes',
    },
    {
      title: 'الفواتير المشحونة',
      href: '/admin/sales/shipped',
    },
  ];

  return (
    <DashboardLayout>
      <div dir={isRtl ? 'rtl' : 'ltr'} className={isRtl ? 'text-right' : 'text-left'}>
        <SalesLayoutShell title="إدارة المبيعات" links={navItems}>
          {children}
        </SalesLayoutShell>
      </div>
    </DashboardLayout>
  );
}
