import React from 'react';
import { PageID, AmityPostTargetSelectionPageType } from '../../../enums';
import { useBehaviour } from '../../../providers/BehaviourProvider';
import TargetSelectionPage from '../../../components/TargetSelectionPage/TargetSelectionPage';
import { useNavigation } from '@react-navigation/native';
import { serializeCommunity } from '../../../utils';
const AmityPostTargetSelectionPage = ({
  postType
}) => {
  const {
    AmityPostTargetSelectionPageBehavior
  } = useBehaviour();
  const navigation = useNavigation();
  const onSelectFeed = ({
    targetId,
    targetName,
    targetType,
    community,
    postSetting,
    needApprovalOnPostCreation,
    isPublic
  }) => {
    if (postType === AmityPostTargetSelectionPageType.post) {
      if (AmityPostTargetSelectionPageBehavior.goToPostComposerPage) {
        return AmityPostTargetSelectionPageBehavior.goToPostComposerPage({
          community: serializeCommunity(community),
          targetId,
          targetType
        });
      }
      return navigation.navigate('CreatePost', {
        community: serializeCommunity(community),
        targetType,
        targetId
      });
    }
    if (postType === AmityPostTargetSelectionPageType.poll) {
      if (AmityPostTargetSelectionPageBehavior.goToPollComposerPage) {
        return AmityPostTargetSelectionPageBehavior.goToPollComposerPage({
          targetId,
          targetType,
          targetName,
          postSetting,
          needApprovalOnPostCreation,
          isPublic
        });
      }
      return navigation.navigate('CreatePoll', {
        targetId,
        targetType,
        targetName,
        postSetting,
        needApprovalOnPostCreation,
        isPublic
      });
    }
    if (postType === AmityPostTargetSelectionPageType.livestream) {
      if (AmityPostTargetSelectionPageBehavior.goToCreateLivestreamPage) {
        return AmityPostTargetSelectionPageBehavior.goToCreateLivestreamPage({
          targetId,
          targetType,
          targetName
        });
      }
      return navigation.navigate('CreateLivestream', {
        targetId,
        targetType,
        targetName
      });
    }
  };
  const onClickClose = () => {
    if (AmityPostTargetSelectionPageBehavior !== null && AmityPostTargetSelectionPageBehavior !== void 0 && AmityPostTargetSelectionPageBehavior.onClickClose) {
      AmityPostTargetSelectionPageBehavior.onClickClose();
    }
  };
  return /*#__PURE__*/React.createElement(TargetSelectionPage, {
    pageId: PageID.select_post_target_page,
    onSelectFeed: onSelectFeed,
    onClickClose: onClickClose
  });
};
export default /*#__PURE__*/React.memo(AmityPostTargetSelectionPage);
//# sourceMappingURL=TargetSelection.js.map