import DashboardLayout from "@/components/layout/dashboard-layout";
import { getTranslations, getCurrentLocale } from "@/lib/i18n";
import { DataNav } from "@/components/admin/data-nav";

export default async function PurchasesLayout({
    children,
}: {
    children: React.ReactNode;
}) {
    const locale = await getCurrentLocale();
    const t = getTranslations(locale);
    const tPurchases = t.Purchases ?? {};
    const tDashboardLayout = t.DashboardLayout ?? {};

    const navLinks = [
        {
            title: tPurchases.invoicesTab ?? 'فواتير المشتريات',
            href: '/admin/purchases',
            subLinks: [
                {
                    title: tPurchases.newOrderTab ?? 'إنشاء أمر',
                    href: '/admin/purchases',
                },
                {
                    title: tPurchases.historyTab ?? 'الأوامر السابقة',
                    href: '/admin/purchases/history',
                }
            ]
        },
        {
            title: tPurchases.creditNotesTab ?? 'إشعارات الدائن',
            href: '/admin/purchases/credit-notes',
            subLinks: [
                {
                    title: tPurchases.newCreditNoteTab ?? 'إنشاء إشعار جديد',
                    href: '/admin/purchases/credit-notes/new',
                },
                {
                    title: tPurchases.creditNotesHistoryTab ?? 'إشعارات سابقة',
                    href: '/admin/purchases/credit-notes/history',
                }
            ]
        },
        {
            title: tPurchases.purchaseReturnsTab ?? 'مردودات المشتريات',
            href: '/admin/purchases/returns',
        },
        {
            title: tPurchases.paymentVoucherTab ?? 'سند دفع',
            href: '/admin/purchases/payment',
        },
        {
            title: tPurchases.expiryCheckTab ?? 'فحص صلاحية الأصناف',
            href: '/admin/purchases/expiry',
        }
    ];

    return (
        <DashboardLayout>
             <div className="grid w-full max-w-[1700px] gap-1 me-auto ms-0 pe-2 sm:pe-4">
                <h1 className="text-3xl font-semibold">{tDashboardLayout.purchases ?? 'المشتريات'}</h1>
                <div className="w-full border-b mt-2 flex justify-end">
                    <DataNav links={navLinks} />
                </div>
                <div className="mt-3">
                    {children}
                </div>
            </div>
        </DashboardLayout>
    );
}

