import TabProduct from "../../../tabProduct/index.js";
import { formatScheduleListByTabs } from "../../schedules/utils.js";
import RenderScheduleItem from "./RenderScheduleItem/index.js";
import React, { useMemo } from "react";
import { Button, Empty, Skeleton } from "antd";
import { locales } from "@pisell/utils";
import classNames from "classnames";
import "./index.less";
//#region src/components/schedules/components/ScheduleList/index.tsx
/**
* 日程列表 展示日程简略信息
* @param props
* @constructor
*/
const ScheduleList = (props) => {
	const { dataSource, onItemClick, showDeleteIcon, onDelete, loading, className, addButtonProps, showTabs } = props;
	const renderList = useMemo(() => {
		return formatScheduleListByTabs(dataSource);
	}, [dataSource]);
	const content = useMemo(() => {
		if (dataSource.length === 0) return /* @__PURE__ */ React.createElement(Empty, {
			image: Empty.PRESENTED_IMAGE_SIMPLE,
			description: locales.getText("pisell2.text.schedules.no-schedules")
		});
		if (showTabs) return /* @__PURE__ */ React.createElement(TabProduct, {
			scrollDom: ".pisell-lowcode__schedules-module-content-wrap",
			list: renderList,
			name: "schedule",
			renderItem: (item) => {
				return /* @__PURE__ */ React.createElement(RenderScheduleItem, {
					item,
					key: item.id,
					showDeleteIcon,
					onItemClick: () => onItemClick === null || onItemClick === void 0 ? void 0 : onItemClick(item),
					onDelete: () => onDelete === null || onDelete === void 0 ? void 0 : onDelete(item)
				});
			}
		});
		else return dataSource.map((item) => {
			return /* @__PURE__ */ React.createElement(RenderScheduleItem, {
				item,
				showDeleteIcon,
				onItemClick: () => onItemClick === null || onItemClick === void 0 ? void 0 : onItemClick(item),
				onDelete: () => 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
	}, content, addButtonProps ? /* @__PURE__ */ React.createElement(Button, addButtonProps) : null));
};
//#endregion
export { ScheduleList as default };
