import { useEffect, useState } from 'react';
export const useLogic = ({ action }) => {
    const { loading, disabledReason, name } = action;
    const [isVisibleTooltip, setVisibleTooltip] = useState(false);
    const handleOpenTooltip = () => setVisibleTooltip(true);
    const handleCloseTooltip = () => setVisibleTooltip(false);
    useEffect(() => {
        if (loading) {
            setVisibleTooltip(false);
        }
    }, [loading]);
    const title = disabledReason || name;
    return {
        tooltipProps: {
            title,
            open: isVisibleTooltip,
            onOpen: handleOpenTooltip,
            onClose: handleCloseTooltip,
        },
    };
};
