import React, { useMemo } from 'react';
import classNames from 'classnames';
import { Skeleton, Button, Empty } from 'antd';
import TabProduct from "../../../tabProduct";
import { locales } from '@pisell/utils';
import { formatScheduleListByTabs } from "../../schedules/utils";
import RenderScheduleItem from "./RenderScheduleItem";
import "./index.less";
/**
 * 日程列表 展示日程简略信息
 * @param props
 * @constructor
 */
var ScheduleList = function ScheduleList(props) {
  var dataSource = props.dataSource,
    _onItemClick = props.onItemClick,
    showDeleteIcon = props.showDeleteIcon,
    _onDelete = props.onDelete,
    loading = props.loading,
    className = props.className,
    addButtonProps = props.addButtonProps,
    showTabs = props.showTabs;

  // 过滤和格式化日程数据
  var renderList = useMemo(function () {
    return formatScheduleListByTabs(dataSource);
  }, [dataSource]);
  var content = useMemo(function () {
    if (dataSource.length === 0) {
      return /*#__PURE__*/React.createElement(Empty, {
        image: Empty.PRESENTED_IMAGE_SIMPLE,
        description: locales.getText('pisell2.text.schedules.no-schedules')
      });
    }

    // 显示tab
    if (showTabs) {
      return /*#__PURE__*/React.createElement(TabProduct, {
        scrollDom: ".pisell-lowcode__schedules-module-content-wrap",
        list: renderList,
        name: "schedule",
        renderItem: function renderItem(item) {
          return /*#__PURE__*/React.createElement(RenderScheduleItem, {
            item: item,
            key: item.id,
            showDeleteIcon: showDeleteIcon,
            onItemClick: function onItemClick() {
              return _onItemClick === null || _onItemClick === void 0 ? void 0 : _onItemClick(item);
            },
            onDelete: function onDelete() {
              return _onDelete === null || _onDelete === void 0 ? void 0 : _onDelete(item);
            }
          });
        }
      });
    } else {
      return dataSource.map(function (item) {
        return /*#__PURE__*/React.createElement(RenderScheduleItem, {
          item: item,
          showDeleteIcon: showDeleteIcon,
          onItemClick: function onItemClick() {
            return _onItemClick === null || _onItemClick === void 0 ? void 0 : _onItemClick(item);
          },
          onDelete: function onDelete() {
            return _onDelete === null || _onDelete === void 0 ? void 0 : _onDelete(item);
          }
        });
      });
    }
  }, [dataSource, showDeleteIcon, showTabs]);
  return /*#__PURE__*/React.createElement("div", {
    className: classNames('pisell-lowcode__schedule-list', className)
  }, /*#__PURE__*/React.createElement(Skeleton, {
    active: true,
    round: true,
    loading: loading
  }, content, addButtonProps ? /*#__PURE__*/React.createElement(Button, addButtonProps) : null));
};
export default ScheduleList;