diff --git a/src/stores/useFunctionStore.ts b/src/stores/useFunctionStore.ts index 212c803..2977e5c 100644 --- a/src/stores/useFunctionStore.ts +++ b/src/stores/useFunctionStore.ts @@ -1,4 +1,6 @@ +/* eslint-disable react-hooks/rules-of-hooks */ /* eslint-disable @typescript-eslint/no-explicit-any */ +import { useNavigate } from "react-router-dom"; import { create } from "zustand"; interface IFunction { @@ -6,17 +8,20 @@ interface IFunction { } interface FunctionState { - functions: IFunction[]; + functions: IFunction; } -const useFunctionStore = create(() => ({ - functions: [ - { - test: (value1: any, value2: any) => { - return value1 + value2; - }, +const navigate = useNavigate(); + +const useFunctionStore = create((set, get) => ({ + functions: { + goToUrl: (url: string) => { + navigate(url); }, - ], + }, + callFunction: (name: string) => { + get().functions[name].apply(get().functions, []); + }, })); export default useFunctionStore;