/* eslint-disable react-hooks/exhaustive-deps */ 'use client' import colors from '@/con/colors'; import { Stack, Tabs, TabsList, TabsPanel, TabsTab, Title } from '@mantine/core'; 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: "Kegiatan Desa", value: "kegiatanDesa", href: "/admin/lingkungan/gotong-royong/kegiatan-desa" }, { label: "Kategori Kegiatan", value: "kategoriKegiatan", href: "/admin/lingkungan/gotong-royong/kategori-kegiatan" }, ]; const curentTab = tabs.find(tab => tab.href === pathname) const [activeTab, setActiveTab] = useState(curentTab?.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 ( Gotong Royong {tabs.map((e, i) => ( {e.label} ))} {tabs.map((e, i) => ( {/* Konten dummy, bisa diganti tergantung routing */} <> ))} {children} ); } export default LayoutTabs;