import { getText } from "../../../../../../../locales/index.js";
import { formatDate } from "../../utils/date.js";
import { copyText } from "../../utils/file.js";
import React, { forwardRef, useImperativeHandle, useMemo, useState } from "react";
import { Modal, Table } from "antd";
import "./index.less";
//#region src/components/table/Actions/component/ExportImport/components/ImportLog/Detail.tsx
const Detail = (props, ref) => {
	const [list, setList] = useState([]);
	const [open, setOpen] = useState(false);
	const columns = [
		{
			title: getText("table-action-export-import-log-name"),
			dataIndex: "file_name"
		},
		{
			title: getText("table-action-export-import-log-result"),
			dataIndex: "result",
			render: (text) => {
				return /* @__PURE__ */ React.createElement("div", null, getText("table-action-export-import-log-ok")((text === null || text === void 0 ? void 0 : text.success) || 0), (text === null || text === void 0 ? void 0 : text.fail) ? getText("table-action-export-import-log-err")((text === null || text === void 0 ? void 0 : text.fail) || 0) : null);
			}
		},
		{
			title: getText("table-action-export-import-file-account"),
			dataIndex: "account",
			render: (text) => {
				return text ? /* @__PURE__ */ React.createElement("div", null, `${(text === null || text === void 0 ? void 0 : text.first_name) || ""} ${(text === null || text === void 0 ? void 0 : text.last_name) || ""}`) : null;
			}
		},
		{
			title: getText("table-action-export-import-file-created"),
			dataIndex: "created_at",
			render: (text) => formatDate(text)
		}
	];
	const modalContent = useMemo(() => {
		var _list$2;
		return /* @__PURE__ */ React.createElement("div", { className: "export-history-content" }, /* @__PURE__ */ React.createElement(Table, {
			rowClassName: "antd-table-row",
			columns,
			dataSource: list,
			pagination: false,
			rowKey: (record) => record.id,
			scroll: { x: true }
		}), /* @__PURE__ */ React.createElement("div", { className: "error-content" }, /* @__PURE__ */ React.createElement("div", { className: "header" }, /* @__PURE__ */ React.createElement("span", null, getText("table-action-export-import-log-err-log")), /* @__PURE__ */ React.createElement("a", { onClick: () => {
			var _list$;
			copyText((list === null || list === void 0 || (_list$ = list[0]) === null || _list$ === void 0 || (_list$ = _list$.result) === null || _list$ === void 0 || (_list$ = _list$.fail_msg) === null || _list$ === void 0 ? void 0 : _list$.join(",")) || "");
		} }, getText("table-action-export-import-log-copy"))), /* @__PURE__ */ React.createElement("div", { className: "box" }, list === null || list === void 0 || (_list$2 = list[0]) === null || _list$2 === void 0 || (_list$2 = _list$2.result) === null || _list$2 === void 0 || (_list$2 = _list$2.fail_msg) === null || _list$2 === void 0 ? void 0 : _list$2.map((i, index) => {
			return /* @__PURE__ */ React.createElement("div", { key: index }, i);
		}))));
	}, [list]);
	useImperativeHandle(ref, () => {
		return { open: (params) => {
			setList((params === null || params === void 0 ? void 0 : params.list) || []);
			setOpen(true);
		} };
	});
	return /* @__PURE__ */ React.createElement(Modal, {
		open,
		title: getText("table-action-export-import-log-detail-title"),
		width: 900,
		footer: null,
		destroyOnClose: true,
		onCancel: () => setOpen(false),
		className: "antd-modal-detail-modal"
	}, modalContent);
};
var Detail_default = forwardRef(Detail);
//#endregion
export { Detail_default as default };
