import React, { useCallback, useEffect, useState } from 'react'; import { loadCustomTabs, type IndicatorCustomTab } from '../utils/indicatorCustomTabsStorage'; import { applyIndicatorTab } from '../utils/indicatorTabApply'; const IcApplyTab = () => ( ); interface Props { onAddMany?: (types: string[]) => void; onAdd?: (type: string) => void; } const IndicatorTabQuickButtons: React.FC = ({ onAddMany, onAdd }) => { const [customTabs, setCustomTabs] = useState(() => loadCustomTabs()); const refreshTabs = useCallback(() => { setCustomTabs(loadCustomTabs()); }, []); useEffect(() => { refreshTabs(); window.addEventListener('gc-indicator-custom-tabs-changed', refreshTabs); return () => window.removeEventListener('gc-indicator-custom-tabs-changed', refreshTabs); }, [refreshTabs]); if (!onAddMany && !onAdd) return null; const applyMain = () => { applyIndicatorTab({ kind: 'main' }, onAddMany, onAdd); }; const applyCustom = (tab: IndicatorCustomTab) => { applyIndicatorTab({ kind: 'custom', tab }, onAddMany, onAdd); }; return (
{customTabs.map(tab => ( ))}
); }; export default IndicatorTabQuickButtons;