import { memo, useEffect, useState } from 'react';
import { AmityPostContentComponentStyleEnum } from '../../../../enums/AmityPostContentComponentStyle';
import { AmityPostEngagementActionsSubComponent } from './Components';
import { CommunityRepository } from '@amityco/ts-sdk-react-native';
import { ComponentID, PageID } from '../../../../enums';
const AmityPostEngagementActionsComponent = ({
  AmityPostContentComponentStyle = AmityPostContentComponentStyleEnum.detail,
  targetId,
  targetType,
  postId,
  pageId = PageID.WildCardPage,
  componentId = ComponentID.WildCardComponent
}) => {
  const [communityData, setCommunityData] = useState(null);
  useEffect(() => {
    if (targetType === 'community' && targetId) {
      CommunityRepository.getCommunity(targetId, ({
        data,
        error,
        loading
      }) => {
        if (!error && !loading) {
          setCommunityData(data);
        }
      });
    }
  }, [targetId, targetType]);
  if (AmityPostContentComponentStyle === AmityPostContentComponentStyleEnum.feed) return /*#__PURE__*/React.createElement(AmityPostEngagementActionsSubComponent.FeedStyle, {
    community: communityData,
    pageId: pageId,
    componentId: componentId,
    postId: postId
  });
  if (AmityPostContentComponentStyle === AmityPostContentComponentStyleEnum.detail) return /*#__PURE__*/React.createElement(AmityPostEngagementActionsSubComponent.DetailStyle, {
    community: communityData,
    postId: postId,
    pageId: pageId,
    componentId: componentId
  });
  return null;
};
export default /*#__PURE__*/memo(AmityPostEngagementActionsComponent);
//# sourceMappingURL=EngagementActions.js.map