import React, { useEffect, useState } from 'react'; import { runInAction } from 'mobx'; import { observer } from 'mobx-react-lite'; import { FiltersMap } from '@wix/bex-core'; import { ChangeOrderSmall, ReorderSmall } from '@wix/wix-ui-icons-common/lazy'; import { MultiLevelSortingState, ToolbarCollectionState } from '../../state'; import { MultiLevelSortingPanelEntry } from '../MultiLevelSortingPanel'; import { CounterBadgeButton } from '../CounterBadgeButton'; import { usePageContext } from '@wix/bex-core/react'; import { ResponsiveButton } from '../ResponsiveButton/ResponsiveButton'; import { useBmHarmonyTheme } from '../../hooks/useBmHarmonyTheme'; export interface MultiLevelSortingCTAButtonProps { state: ToolbarCollectionState; } export function _MultiLevelSortingCTAButton( props: MultiLevelSortingCTAButtonProps, ) { const { state } = props; const { panels, container: { translate: t, isPanelLayout }, toolbar: { responsive }, } = state; const { modalsContainerRef } = usePageContext(); const isHarmonyTheme = useBmHarmonyTheme(); const [multiLevelSortingState] = useState(() => runInAction( () => (state.multiLevelSorting ??= new MultiLevelSortingState({ table: state, container: state.container, modalsContainerRef, })), ), ); useEffect(() => multiLevelSortingState.init(), []); useEffect(() => { panels.registerSidePanel('multiLevelSorting', MultiLevelSortingPanelEntry); }, []); return ( : } dataHook="multi-level-sorting-button" onClick={() => { const isOpen = panels.toggleSidePanel('multiLevelSorting'); if (isOpen) { multiLevelSortingState.reportSidePanelOpen(); } else { multiLevelSortingState.reportSidePanelClose({ origin: 'Sort CTA', }); } }} > {t('cairo.table.advanced-sorting.button.cta')} ); } export const MultiLevelSortingCTAButton = observer(_MultiLevelSortingCTAButton);