//事件列表
import { ScrollView, View, Text, Image } from "@tarojs/components";
import Taro from "@tarojs/taro";
import ITag from "../ITag";
import "./index.less";
import map from "@/assets/images/event/map.png";
import time from "@/assets/images/event/time.png";
import { DiscoverEntryDto } from "@/store/report";
interface EventListProps {
  list: API.EventDto[];
  noMoreText: string | undefined;
  eventType: DiscoverEntryDto; //入口，随手拍显示状态，举手之劳不显示
  onScrollToLower: () => void;
}
const EventList: React.FC<EventListProps> = ({
  list = [],
  noMoreText,
  eventType,
  onScrollToLower,
}) => {
  //进入案件详情
  const handleToDetail = (caseId: string) => {
    Taro.navigateTo({
      url: "/pages/Event/view/detail/index?caseId=" + caseId,
    });
  };

  return (
    <ScrollView
      className="scrollview"
      style={{ height: "88vh" }}
      scrollY
      onScrollToLower={onScrollToLower}
    >
      <>
        {list?.map((it) => (
          <View
            className="item"
            key={it.id}
            onClick={() => handleToDetail(it.id)}
          >
            <View className="top">
              <Text className="name textellipsis">{it.standardEventTitle}</Text>
              {eventType === "take" && (
                <ITag title={it.caseStatusText} color={it.caseStatusColor} />
              )}
            </View>
            <View className="text">
              <Image src={map} className="pre-icon1" />
              <Text className="textellipsis address">{it.address}</Text>
            </View>
            <View className="text">
              <Image src={time} className="pre-icon" />
              {it.reportTime}
            </View>
          </View>
        ))}
        {list.length > 10 && <View className="seat">{noMoreText}</View>}
      </>
    </ScrollView>
  );
};
export default EventList;
