import { observer } from 'mobx-react-lite'; import { CounterBadge, CounterBadgeProps } from '@wix/design-system'; import React from 'react'; import { useFilterValueTotalState, UseFilterValueTotalStateParams, } from './useFilterValueTotalState'; import { FiltersMap } from '@wix/bex-core'; import { initTabTotal } from '../../state/initTabTotal'; import { useBmHarmonyTheme } from '../../hooks/useBmHarmonyTheme'; export interface TabCounterBadgeProps extends UseFilterValueTotalStateParams, Partial {} function _TabCounterBadge( props: TabCounterBadgeProps, ) { const isHarmonyTheme = useBmHarmonyTheme(); const defaultSkin = isHarmonyTheme ? 'general' : 'neutralStandard'; const defaultSize = isHarmonyTheme ? 'tiny' : 'small'; const { value, skin = defaultSkin, size = defaultSize, ...rest } = props; const state = useFilterValueTotalState(props); const { totalsCollection: { totalStatus, total, lifecycleState }, } = state; return totalStatus === 'success' && lifecycleState === 'result' ? ( {total} ) : null; } _TabCounterBadge.initTabTotal = initTabTotal; export const TabTotalCounterBadge = observer(_TabCounterBadge); TabTotalCounterBadge.displayName = 'TabTotalCounterBadge'; TabTotalCounterBadge.initTabTotal = initTabTotal;