import React from 'react'

import { IIndustyListItem } from 'Indepth/Indepth.service'
import styles from '../css/ItemComponent.module.scss'
export interface IIndustrialSourceCardProps {
  item: IIndustyListItem
}
/**资源包组件 */
const IndustrialSourceCard: React.FC<IIndustrialSourceCardProps> = props => {
  const { item } = props

  const handleToPage = () => {
    // 1是弘则资源包，2是研选资源包
    const urlType: {
      [key: number]: string
    } = {
      1: `${window.location.origin}/indepth/info/${item.ChartPermissionId}/${item.IndustrialManagementId}`,
      2: `${window.location.origin}/community/theme/${item.IndustrialManagementId}`
    }
    const url = urlType[item.Source]
    if (!url) return
    window.open(url)
  }
  if (!item) return null
  return (
    <div onClick={handleToPage}>
      <div className={styles['item-article']}>
        <div className="item-article-title">
          {item.IndustryName}
          {item.Source === 1 ? '（弘则资源包）' : '（买方研选主题）'}
        </div>
        <div className="item-source-height">
          {item.IndustrialSubjectList?.map(item => (
            <div className="source-company-name" key={item.IndustrialSubjectId}>
              {item.SubjectName}
            </div>
          ))}
          {/* {handleInsertDiv(item.IndustrialSubjectList || [])} */}
        </div>
        <div className="item-time-right">
          <div className="item-article-publistdate">
            <span>{item.UpdateTime}更新</span>
            {item.IsRed && <span className="red-point m-l-sm" />}
          </div>
        </div>
      </div>
    </div>
  )
}

export default IndustrialSourceCard
