function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
import { useState, useEffect } from 'react';
import { Iconfont } from '@pisell/materials';
import { Space } from 'antd';
import { weekListText } from "../../state";
import Item from "../../Item";
import { getMonthIndex, getCurrentStatus, formatDate } from "../../../../utils";
import "./index.less";
var WeekItem = function WeekItem(props) {
  var weekList = props.weekList,
    currentDate = props.currentDate,
    setCurrentDate = props.setCurrentDate,
    isActive = props.isActive,
    productId = props.productId,
    dateLimitData = props.dateLimitData,
    getLimitData = props.getLimitData,
    cutTime = props.cutTime;

  // 显示月份的位置
  var _useState = useState([]),
    _useState2 = _slicedToArray(_useState, 2),
    monthIndex = _useState2[0],
    setMonthIndex = _useState2[1];
  useEffect(function () {
    if (isActive && productId) {
      // getLimitData(weekList[0], weekList[6]);
    }
  }, [isActive, productId, weekList]);
  useEffect(function () {
    var arr = getMonthIndex(weekList);
    setMonthIndex(arr);
  }, [weekList]);
  return /*#__PURE__*/React.createElement("div", {
    className: "week-item-wrap"
  }, /*#__PURE__*/React.createElement("div", {
    className: "week-item-content"
  }, /*#__PURE__*/React.createElement(Iconfont, {
    type: "pisell2-arrow-left",
    className: "week-item__icon"
  }), /*#__PURE__*/React.createElement(Space, {
    size: 8
  }, weekList === null || weekList === void 0 ? void 0 : weekList.map(function (item, index) {
    var _getCurrentStatus = getCurrentStatus(dateLimitData, item, cutTime),
      disabled = _getCurrentStatus.disabled,
      currentStatus = _getCurrentStatus.currentStatus;
    return /*#__PURE__*/React.createElement(Item, {
      key: index,
      date: formatDate(item, 'DD'),
      week: weekListText[index],
      dateText: item,
      disabled: disabled,
      status: currentStatus,
      select: currentDate === item,
      showMonth: monthIndex.includes(index),
      onClick: function onClick(e) {
        setCurrentDate(item);
      }
    });
  })), /*#__PURE__*/React.createElement(Iconfont, {
    type: "pisell2-arrow-right",
    className: "week-item__icon"
  })));
};
export default WeekItem;