/*
 * @Description:
 * @Autor: 24
 * @Date: 2021-12-06 13:43:14
 * @LastEditors: lanzhisheng
 * @LastEditTime: 2022-04-08 16:17:34
 */
import React, { FC } from "react";
import { View, Text } from "@tarojs/components";

const poolType = {
  // 2-跟股池，3-交易池，4-精选池
  2: "跟踪池",
  3: "交易池",
  4: "精选池",
};

type Props = {
  dataItem: any;
  onClick: any;
  updateSelfStock: any;
  type: number;
};
const SearchContentItem: FC<Props> = (props) => {
  const { dataItem, onClick, updateSelfStock, type } = props;
  if (!dataItem) return null;

  return (
    <View className="sharesItemContainer">
      <View className="at-row itemContainer">
        <View className="at-col item1" onClick={() => onClick(dataItem)}>
          <View className="name">{dataItem.secuAbbr}</View>
          <View className="tips">
            <View className="industry type1">{dataItem.industryName}</View>
            <Text>{dataItem.secuCode}</Text>
          </View>
        </View>
        {type === 2 && (
          <View>
            <Text className="status-label">股票池状态：</Text>{" "}
            <Text className="status-value">{poolType[dataItem["inPool"]]}</Text>
          </View>
        )}
        {type === 1 && (
          <View
            className="at-col item3"
            onClick={() => {
              updateSelfStock(dataItem);
            }}
          >
            <View
              className={`recomendBtn ${
                dataItem?.isSelfStock ? "noAddBtn" : ""
              }`}
            >
              <Text>{dataItem?.isSelfStock ? "取消自选" : "加自选"}</Text>
            </View>
          </View>
        )}
      </View>
    </View>
  );
};

export default SearchContentItem;
