"use client";

import { createContext, type ReactNode } from "react";
import { useToolsMenu, type UseToolsMenuReturn } from "@/hooks/useToolsMenu";

export const ToolsMenuContext = createContext<UseToolsMenuReturn>({
  types: [],
  tools: [],
  typeDefinitions: {},
  loading: true,
  error: null,
  addType: () => Promise.reject(new Error("No ToolsMenuProvider")),
  updateType: () => Promise.reject(new Error("No ToolsMenuProvider")),
  deleteType: () => Promise.reject(new Error("No ToolsMenuProvider")),
  updateTypeFields: () => Promise.reject(new Error("No ToolsMenuProvider")),
  addTool: () => Promise.reject(new Error("No ToolsMenuProvider")),
  updateTool: () => Promise.reject(new Error("No ToolsMenuProvider")),
  deleteTool: () => Promise.reject(new Error("No ToolsMenuProvider")),
  updateViewOrder: () => Promise.reject(new Error("No ToolsMenuProvider")),
  refresh: () => {},
});

export function ToolsMenuProvider({ children }: { children: ReactNode }) {
  const toolsMenu = useToolsMenu();
  return <ToolsMenuContext value={toolsMenu}>{children}</ToolsMenuContext>;
}
