import { memo } from 'react';

import useCommunityFeature from 'src/hooks/useCommunityFeature';
import {
  feedKeys,
  updateSearchPostListDataReaction,
} from 'src/pages/dashboard/feed/queries';
import { getList } from 'src/services/posts';

import { CommunityFeature } from 'src/types/communityFeatures';

import { PostSearch } from './PostSearch';

const FeedPostSearch = () => {
  const canViewGroupPostsInFeed = useCommunityFeature(
    CommunityFeature.VIEW_GROUP_POSTS_IN_FEED,
  );

  return (
    <PostSearch
      queryKey={feedKeys.search}
      fetchFn={(pageParam, query) =>
        getList(pageParam, canViewGroupPostsInFeed, query)
      }
      updateReactionFn={updateSearchPostListDataReaction}
    />
  );
};

export default memo(FeedPostSearch);
