import React from 'react';
import {Navigation} from '@interfaces/navigation';
import ArticleCommentDetail from '@modules/article/screens/ArticleCommentDetail';
import GroupCommentDetail from '@modules/group/screens/GroupCommentDetail';
import MarketplaceCommentDetail from '@modules/marketplace/screens/MarketplaceCommentDetail';
import {Screens} from '@shared/constants';

import FeedCommentDetail from './components/FeedCommentDetail';

function CommentDetailRefactored(props: Navigation<Screens.COMMENT_DETAIL>) {
  const {
    parentCommentId,
    isReplying,
    postId,
    articleId,
    groupId,
    isMarketplace,
    comesFromPush,
  } = props.route.params;
  if (groupId)
    return (
      <GroupCommentDetail
        groupId={groupId}
        commentId={parentCommentId}
        comesFromPush={comesFromPush}
        isReplying={isReplying}
        postId={postId}
      />
    );
  if (articleId)
    return (
      <ArticleCommentDetail
        articleId={articleId}
        commentId={parentCommentId}
        comesFromPush={comesFromPush}
        isReplying={isReplying}
      />
    );

  if (isMarketplace) {
    return (
      <MarketplaceCommentDetail
        commentId={parentCommentId}
        comesFromPush={comesFromPush}
        isReplying={isReplying}
        postId={postId}
      />
    );
  }

  return (
    <FeedCommentDetail
      commentId={parentCommentId}
      isReplying={isReplying}
      postId={postId}
      comesFromPush={comesFromPush}
    />
  );
}

export default CommentDetailRefactored;
