import React from 'react'

import { IHomeChartListItem } from 'Material/Material.service'
import ActivityCard from 'Activity/components/ActivityCard'
import ActivitySpecialCard from 'Activity/components/ActivitySpecialCard'
import { INewestList } from 'Newest/Newest.service'
import MeetingCard from './MeetingCard'
import SummaryCard from './SummaryCard'
import VideoAudioCard from './VideoAudioCard'
import ArticleCard from './ArticleCard'
import SearchArticleCard from './SearchArticleCard'
import ProductInteriorCard from './ProductInteriorCard'
import IndustrialSourceCard from './IndustrialSourceCard'
import ReportSelectionCard from './ReportSelectionCard'
import YanxuanSpecialCard from './YanxuanSpecialCard'
import YanxuanSpecialAuthorCard from './YanxuanSpecialAuthorCard'

export enum IItemType {
  MyChart = 'myChart', // 我收藏的图表
  NormalChart = 'normalChart', // 素材库中的图表
  Article = 'article', // 报告
  SearchArticle = 'searchArticle', // 搜索时的报告
  NewChart = 'newchart', // 最新与搜索时图表
  RoadshowLibrary = 'roadshowLibrary', // 素材库中的微路演
  Roadshow = 'roadshow', // 微路演
  Activity = 'activity', // 活动
  Activityvideo = 'activityvideo', // 活动视频
  Activityvoice = 'activityvoice', // 活动音频
  Activityspecial = 'activityspecial', // 专项调研活动
  Researchsummary = 'researchsummary', // 本周研究汇总
  Minutessummary = 'minutessummary', // 上周纪要汇总
  Meetingreviewchapt = 'meetingreviewchapt', // 晨会精华
  Productinterior = 'productinterior', // 产品内测
  Industrialsource = 'industrialsource', // 产业资源包
  ReportSelection = 'reportselection', // 重点公司展示样式
  YanxuanSpecial = 'yanxuanspecial', // 专栏笔记/观点
  AskserieVideo = 'askserievideo', // 问系列视频
  YanxuanSpecialAuthor = 'yanxuanspecialauthor' // 专栏作者
}
interface IItemComponentProps {
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  item: INewestList | any
  itemType: IItemType
  audioPlayId?: number
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  handleItemClick?: (item: any) => void // 整一块的点击
}

const ItemComponent: React.FC<IItemComponentProps> = props => {
  const { item, itemType, audioPlayId, handleItemClick } = props

  const handleClick = () => {
    handleItemClick && handleItemClick(item)
  }

  return (
    <>
      {itemType === IItemType.Article && <ArticleCard item={item?.Article || item} />}
      {itemType === IItemType.SearchArticle && <SearchArticleCard item={item} />}
      {itemType === IItemType.Activity && (
        <ActivityCard item={item.Activity} hasBtn={true} selfChange={true} btnGrous={'smcard'} />
      )}
      {itemType === IItemType.Activityspecial && (
        <ActivitySpecialCard item={item.Activityspecial} hasBtn={true} selfChange={true} btnGrous={'smcard'} />
      )}
      {(itemType === IItemType.AskserieVideo ||
        itemType === IItemType.Activityvoice ||
        itemType === IItemType.Activityvideo ||
        itemType === IItemType.RoadshowLibrary ||
        itemType === IItemType.Roadshow) && (
        <VideoAudioCard
          item={item.AskserieVideo || item.Activityvideo || item.Activityvoice || item.Roadshow || item}
          onItemClick={handleClick}
          audioPlayId={audioPlayId}
        />
      )}
      {itemType === IItemType.Meetingreviewchapt && <MeetingCard item={item.Meetingreviewchapt} />}
      {(itemType === IItemType.Researchsummary || itemType === IItemType.Minutessummary) && (
        <SummaryCard item={item.Researchsummary || item.Minutessummary} itemType={itemType} />
      )}
      {itemType === IItemType.Productinterior && <ProductInteriorCard item={item.ProductInterior} />}
      {itemType === IItemType.Industrialsource && <IndustrialSourceCard item={item.IndustrialResource} />}
      {itemType === IItemType.ReportSelection && <ReportSelectionCard item={item.ReportSelection} />}
      {itemType === IItemType.YanxuanSpecial && <YanxuanSpecialCard item={item.YanxuanSpecial} />}
      {itemType === IItemType.YanxuanSpecialAuthor && <YanxuanSpecialAuthorCard item={item.YanxuanSpecialAuthor} />}
    </>
  )
}

export default ItemComponent
