This commit is contained in:
Your Name committed 2026-06-15 19:00:31 -04:00
1 parent a7091858e0
commit ba5c0aba50
9 files changed
+719 -431

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
import { create } from 'zustand';
import { API_BASE } from '@homaroma/types';
export interface MenuLink {
label: Record<string, string>;
url?: string;
links?: MenuLink[];
}
export interface MenuColumn {
title: Record<string, string>;
links: MenuLink[];
}
export interface MegaMenuPayload {
id: string;
label: Record<string, string>;
url?: string;
columns?: MenuColumn[];
}
interface MenuState {
megaMenu: MegaMenuPayload[];
isLoading: boolean;
fetchMegaMenu: () => Promise<void>;
}
export const useMenuStore = create<MenuState>((set) => ({
megaMenu: [],
isLoading: false,
fetchMegaMenu: async () => {
set({ isLoading: true });
try {
const response = await fetch(`${API_BASE}/menus/main`);
const data = await response.json();
set({ megaMenu: data.payload || [], isLoading: false });
} catch (error) {
console.error('Failed to fetch mega menu', error);
set({ isLoading: false });
}
}
}));