import { memo, useState } from 'react';
import { useStyles } from './styles';
import AmityTopSearchBarComponent from '../../features/search/components/TopSearchBar';
import { SafeAreaView } from 'react-native-safe-area-context';
import { useAmityGlobalSearchViewModel } from '../../hooks';
import { TabName } from '../../enums/enumTabName';
import { PageID } from '../../enums';
import { useAmityPage } from '../../hooks';
import NoSearchResult from '../../components/NoSearchResult/NoSearchResult';
import CommunitySearchResult from '../../components/CommunitySearchResult/CommunitySearchResult';
const AmityMyCommunitiesSearchPage = () => {
  const pageId = PageID.social_global_search_page;
  const {
    isExcluded,
    themeStyles
  } = useAmityPage({
    pageId
  });
  const styles = useStyles(themeStyles);
  const [searchValue, setSearchValue] = useState(null);
  const searchType = TabName.MyCommunities;
  const {
    searchResult,
    onNextMyCommunityPage,
    isLoading
  } = useAmityGlobalSearchViewModel(searchValue, searchType);
  if (isExcluded) return null;
  return /*#__PURE__*/React.createElement(SafeAreaView, {
    style: styles.container
  }, /*#__PURE__*/React.createElement(AmityTopSearchBarComponent, {
    searchType: searchType,
    setSearchValue: setSearchValue
  }), !isLoading && (searchResult === null || searchResult === void 0 ? void 0 : searchResult.length) === 0 ? /*#__PURE__*/React.createElement(NoSearchResult, null) : /*#__PURE__*/React.createElement(CommunitySearchResult, {
    pageId: pageId,
    isFirstTimeLoading: isLoading && !searchResult,
    isLoading: isLoading,
    communities: searchResult,
    onNextPage: onNextMyCommunityPage
  }));
};
export default /*#__PURE__*/memo(AmityMyCommunitiesSearchPage);
//# sourceMappingURL=index.js.map