import axiosInstance from '../lib/axios';
import { HeaderMenu } from '../types/header-menu';

export const headerMenuService = {
    /**
     * Fetch active header menu tree from API
     */
    async getHeaderMenu(): Promise<HeaderMenu[]> {
        try {
            const response = await axiosInstance.get<{ success: boolean; data: HeaderMenu[] }>('/api/header-menu');
            if (response.data.success) {
                return response.data.data;
            }
            return [];
        } catch (error) {
            console.error('Failed to fetch header menu:', error);
            return []; // Fallback to empty menu
        }
    }
};
