import { useStores } from 'client/hooks/useStores';
import { action as resolveAction } from 'core/tools/resolve';

export const useAction = ({ actionName }) => {
  const { calculationStore } = useStores();
  const action = () => {
    resolveAction({ storeName: 'CalculationStore', actionName }).then(
      ({ default: resolvedAction }) => {
        resolvedAction.call(calculationStore);
      },
    );
  };
  return { action };
};
