2022-05-31 15:28:14 +03:00

29 lines
774 B
TypeScript

/* eslint-disable react/jsx-no-bind */
import { observer } from 'mobx-react-lite';
import type { FC } from 'react';
import { useStatus } from 'stores/calculation/statuses/hooks';
import type { Elements } from '../config/map/actions';
import type { ElementsProps } from '../types/elements-props';
type BuilderProps = {
elementName: Elements;
valueName: string;
};
export default function buildAction(
Component: FC<any>,
{ elementName, valueName: actionName }: BuilderProps
) {
return observer<ElementsProps[typeof elementName]>((props) => {
const status = useStatus(elementName);
return (
<Component
status={status}
action={() => import(`process/${actionName}`).then((m) => m.default())}
{...props}
/>
);
});
}