import React, { useState } from 'react' import { SortableMenuTree } from './SortableMenuTree' import { MenuItem } from '@/proxy/menus/menu' import { useMenuData } from '@/utils/hooks/useMenuData' import { FaRegBell, FaSpinner, FaBars, FaRegSave } from 'react-icons/fa' import { Container } from '@/components/shared' import { Helmet } from 'react-helmet' import { useLocalization } from '@/utils/hooks/useLocalization' import { APP_NAME } from '@/constants/app.constant' export const MenuManager = () => { const { menuItems, setMenuItems, loading, error, refetch, saveMenuData } = useMenuData() const [isDesignMode, setIsDesignMode] = useState(true) const [isSaving, setIsSaving] = useState(false) const { translate } = useLocalization() const [saveMessage, setSaveMessage] = useState<{ type: 'success' | 'error' text: string } | null>(null) const handleMenuChange = (updatedItems: MenuItem[]) => { setMenuItems(updatedItems) } const handleSave = async () => { if (!isDesignMode) return try { setIsSaving(true) setSaveMessage(null) await saveMenuData(menuItems) setSaveMessage({ type: 'success', text: 'Menu configuration saved successfully!' }) setTimeout(() => setSaveMessage(null), 3000) setIsDesignMode(false) } catch (err) { setSaveMessage({ type: 'error', text: err instanceof Error ? err.message : 'Failed to save menu configuration', }) setTimeout(() => setSaveMessage(null), 5000) } finally { setIsSaving(false) } } const handleToggleDesignMode = () => { setIsDesignMode(!isDesignMode) setSaveMessage(null) } if (loading) { return (
Loading menu configuration...
) } if (error) { return (

Error Loading Menu

{error}

) } return (
{/* Sol kısım: Başlık */}

Menu Manager

({menuItems.length} root items)
{/* Sağ kısım: Design Mode + Save butonu */}
Design Mode
{ }
{menuItems.length > 0 ? ( ) : (

No menu items found

Try refreshing the page or contact your administrator

)}
) } export default MenuManager