import { memo, useEffect, useState } from 'react';
import { AmityStoryTabComponentEnum } from '../../../../types';
import MyStories from '../../../../components/MyStories';
import CommunityStories from '../../../../components/CommunityStories';
import { CommunityRepository } from '@amityco/ts-sdk-react-native';
import useConfig from '../../../../hooks/useConfig';
import { ComponentID } from '../../../../enums';
const AmityStoryTabComponent = ({
  type,
  targetId
}) => {
  const [communityData, setCommunityData] = useState(null);
  const {
    excludes
  } = useConfig();
  useEffect(() => {
    if (type === AmityStoryTabComponentEnum.communityFeed && targetId) {
      CommunityRepository.getCommunity(targetId, ({
        error,
        loading,
        data
      }) => {
        if (error) return;
        if (!loading) {
          setCommunityData(data);
        }
      });
    }
  }, [targetId, type]);
  if (excludes.includes(`*/${ComponentID.StoryTab}/*`)) return null;
  if (type === AmityStoryTabComponentEnum.globalFeed) {
    return /*#__PURE__*/React.createElement(MyStories, null);
  }
  if (type === AmityStoryTabComponentEnum.communityFeed) {
    return /*#__PURE__*/React.createElement(CommunityStories, {
      community: communityData,
      communityId: targetId
    });
  }
  return null;
};
export default /*#__PURE__*/memo(AmityStoryTabComponent);
//# sourceMappingURL=Tab.js.map