import React, { Component } from "react";
import Taro from "@tarojs/taro";
import { View, Image, Button } from "@tarojs/components";
import Skeleton from "taro-skeleton";
import { getClockState } from "../../utils/tools";
import ListBottomStart from "../../components/common/listBottomStart";
import "./index.less";

class MyList extends Component {
  constructor(props) {
    super(props);
  }

  render() {
    const { type } = this.props
    return (
      <View className="indexPage">
        <View className="list">
          {
            this.props.list.length === 0 && this.props.listState === "LOADING" &&
            this.props.typelist?.map((v) => (
              <Skeleton key={v} title row={3} avatarShape="square" loading />
            ))
          }
          {this.props.list.length > 0 && this.props.list?.map((v, k) => (
            <View
              key={k}
              className="item"
              onClick={(e) => {
                e.stopPropagation();
                Taro.navigateTo({
                  url: `/pages/detail/index?id=${v.id}&type=${type}`,
                });
              }}
            >
              <View className="infor">
                <View className="title">
                  <View className="aname">
                    {v.projectName}
                  </View>
                </View>
                <View className="userName">
                  <View className="uNtext">
                    负责人：{v.adminName}
                  </View>
                </View>
                <View className="userName">
                  <View className="uNtext">
                    研发人员：{v.name}
                  </View>
                </View>
                <View className="userName">
                  <View className="uNtext">
                    打卡工时：{v.duration}
                  </View>
                </View>
                {
                  v.processStatus == 1 &&
                  (
                    type == 0 ?
                      <View style={{ textAlign: "right", color: "blue" }}>已打卡，待审核</View> :
                      <View className="releaseStarts">
                        <View
                          className="punchClock"
                        // onClick={(e) => {
                        //   e.stopPropagation();
                        // }}
                        >
                          去审核
                        </View>
                      </View>
                  )
                }
                {v.processStatus == 2 && <View style={{ textAlign: "right", color: "green" }}>{type == 0 ? "已打卡，已审核" : "已审核"}</View>}
                {v.processStatus == 3 && <View style={{ textAlign: "right", color: "red" }}>{type == 0 ? "已打卡，已驳回" : "已驳回"}</View>}
              </View>
            </View>
          ))}
          <ListBottomStart
            state={this.props.listState}
            reload={() => {
              this.props.onRefresh;
            }}
          />
        </View>
      </View>
    );
  }
}

export default MyList;
