import { FiltersMap, OptionalFiltersMap, PickerState } from '@wix/bex-core'; import { Revert } from '@wix/wix-ui-icons-common'; import React from 'react'; import { Box, Text, TextButton } from '@wix/design-system'; import { CollectionEmptyStateBase, CollectionEmptyStateBaseProps, } from '../CollectionEmptyStateBase'; import { observer } from 'mobx-react-lite'; interface PickerEmptyStateProps extends Omit, 'state'> { hasFilterDropdown?: boolean; state: PickerState; } function _PickerEmptyState( props: PickerEmptyStateProps, ) { const { state, hasFilterDropdown, ...rest } = props; const { collection } = state; const { result: { hasAvailableItems }, translate: t, } = collection; const showFilterOnlyEmptyState = Boolean( hasFilterDropdown && collection.query.search.isEmpty, ); const showFilterWithSearchEmptyState = Boolean( hasFilterDropdown && !collection.query.search.isEmpty, ); const searchOnlyNoResultsStateProps = { state: collection, dataHook: 'picker-no-results-state', title: t('cairo.search.nothingMatches.title', { term: collection.result.originQuery.rawSearch, }), subtitle: ( {t('cairo.search.nothingMatches.text')} } onClick={() => { collection.clearSearch(); collection.searchInputRef?.focus(); }} > {t('cairo.emptyState.reset.button')} ), }; const filterOnlyEmptyStateProps: CollectionEmptyStateBaseProps = { state: collection, dataHook: 'picker-empty-state-only-filter', title: t('cairo.search.noresults.title'), subtitle: t('cairo.selectorModal.searchEmptyState.changeFilter.subtitle'), }; const filterWithSearchEmptyStateProps: CollectionEmptyStateBaseProps = { state: collection, dataHook: 'picker-empty-state-filter-with-search', title: t('cairo.search.nothingMatches.title', { term: collection.result.originQuery.rawSearch, }), subtitle: ( {t('cairo.selectorModal.searchEmptyState.subtitle')} } onClick={() => { collection.clearSearch(); collection.searchInputRef?.focus(); }} > {t('cairo.emptyState.reset.button')} ), }; const getEmptyStateConfig = (): CollectionEmptyStateBaseProps => { if (!hasAvailableItems) { return { state: collection, dataHook: 'picker-empty-state', }; } if (showFilterOnlyEmptyState) { return filterOnlyEmptyStateProps; } if (showFilterWithSearchEmptyState) { return filterWithSearchEmptyStateProps; } return searchOnlyNoResultsStateProps; }; return ; } export const PickerEmptyState = observer(_PickerEmptyState);