/* eslint-disable react-hooks/exhaustive-deps */ 'use client' import colors from '@/con/colors'; import { Box, ScrollArea, Stack, Tabs, TabsList, TabsPanel, TabsTab, Title } from '@mantine/core'; import { IconCategory, IconShoppingBag } from '@tabler/icons-react'; import { usePathname, useRouter } from 'next/navigation'; import React, { useEffect, useState } from 'react'; function LayoutTabs({ children }: { children: React.ReactNode }) { const router = useRouter(); const pathname = usePathname(); const tabs = [ { label: "Produk Pasar Desa", value: "produkpasardesa", href: "/admin/ekonomi/pasar-desa/produk-pasar-desa", icon: }, { label: "Kategori Produk", value: "kategoriproduk", href: "/admin/ekonomi/pasar-desa/kategori-produk", icon: }, ]; const currentTab = tabs.find((tab) => tab.href === pathname); const [activeTab, setActiveTab] = useState( currentTab?.value || tabs[0].value ); const handleTabChange = (value: string | null) => { const tab = tabs.find((t) => t.value === value); if (tab) { router.push(tab.href); } setActiveTab(value); }; useEffect(() => { const match = tabs.find((tab) => tab.href === pathname); if (match) { setActiveTab(match.value); } }, [pathname]); return ( Pasar Desa {/* ✅ Scroll horizontal wrapper */} {tabs.map((tab, i) => ( {tab.label} ))} {tabs.map((tab, i) => ( {tab.label} ))} {tabs.map((tab, i) => ( {children} ))} ); } export default LayoutTabs;