var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/table/Actions/component/ExportImport/components/ExportFile/index.tsx
var ExportFile_exports = {};
__export(ExportFile_exports, {
  default: () => ExportFile_default
});
module.exports = __toCommonJS(ExportFile_exports);
var import_ahooks = require("ahooks");
var import_antd = require("antd");
var import_react = __toESM(require("react"));
var import_useEngineContext = __toESM(require("../../../../../../../hooks/useEngineContext"));
var import_locales = require("../../../../../../../locales/index");
var import_serve = require("../../../../../serve");
var import_utils = require("../../../../../utils");
var import_date = require("../../utils/date");
var import_download = __toESM(require("../../utils/download"));
var import_index = require("./index.less");
var defaultData = {
  skip: 1,
  num: 10
};
var exportStatusOptions = {
  pending: (0, import_locales.getText)("table-action-export-import-file-pending"),
  processing: (0, import_locales.getText)("table-action-export-import-file-processing"),
  completed: (0, import_locales.getText)("table-action-export-import-file-completed"),
  complete: (0, import_locales.getText)("table-action-export-import-file-completed")
};
var ExportFile = (props) => {
  const { exportImport } = props;
  const { apiUrl, otherParams } = exportImport;
  const [list, setList] = (0, import_react.useState)([]);
  const context = (0, import_useEngineContext.default)();
  import_utils.request.setRequest(context.appHelper.utils.request);
  const _historyList = (0, import_ahooks.useRequest)(import_serve.getExportFile, {
    manual: true,
    onSuccess: (res) => {
      var _a;
      if (res.code == 200) {
        setList(((_a = res.data) == null ? void 0 : _a.list) || []);
      }
    }
  });
  const init = () => {
    const _defaultParams = {
      ...defaultData,
      ...otherParams,
      url: apiUrl == null ? void 0 : apiUrl.export_file
    };
    _historyList.run(_defaultParams);
  };
  (0, import_react.useEffect)(() => {
    init();
  }, [exportImport]);
  const columns = [
    {
      title: (0, import_locales.getText)("table-action-export-import-file-name"),
      dataIndex: "file_name",
      render: (text, record) => {
        return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, record.status == "completed" || record.status == "complete" ? /* @__PURE__ */ import_react.default.createElement(
          "a",
          {
            onClick: () => {
              (0, import_download.default)(record.url, text);
            }
          },
          text
        ) : /* @__PURE__ */ import_react.default.createElement("span", null, text));
      }
    },
    {
      title: (0, import_locales.getText)("table-action-export-import-file-content"),
      dataIndex: "setting",
      render: (text, record) => {
        var _a, _b, _c;
        return /* @__PURE__ */ import_react.default.createElement("div", null, ((_b = (_a = text == null ? void 0 : text.params) == null ? void 0 : _a.ids) == null ? void 0 : _b.length) ? (0, import_locales.getText)("table-action-export-import-file-content-part") : (0, import_locales.getText)("table-action-export-import-file-content-all"), " ", (0, import_locales.getText)("table-action-export-import-file-record")(
          `${((_c = record == null ? void 0 : record.result) == null ? void 0 : _c.total) || 0}`
        ));
      }
    },
    {
      title: (0, import_locales.getText)("table-action-export-import-file-status"),
      dataIndex: "status",
      render: (text) => exportStatusOptions[text]
    },
    {
      title: (0, import_locales.getText)("table-action-export-import-file-account"),
      dataIndex: "account",
      render: (text) => {
        return text ? /* @__PURE__ */ import_react.default.createElement("div", null, `${(text == null ? void 0 : text.first_name) || ""} ${(text == null ? void 0 : text.last_name) || ""}`) : null;
      }
    },
    {
      title: (0, import_locales.getText)("table-action-export-import-file-created"),
      dataIndex: "created_at",
      render: (text) => (0, import_date.formatDate)(text)
    }
  ];
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "export-history-content" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Spin, { spinning: _historyList == null ? void 0 : _historyList.loading }, /* @__PURE__ */ import_react.default.createElement("div", { className: "content-hint" }, (0, import_locales.getText)("table-action-export-import-file-hint"), /* @__PURE__ */ import_react.default.createElement("a", { onClick: () => init() }, (0, import_locales.getText)("table-action-export-import-file-refresh"))), /* @__PURE__ */ import_react.default.createElement(
    import_antd.Table,
    {
      rowClassName: "antd-table-row",
      columns,
      dataSource: list,
      pagination: false,
      rowKey: (record) => record.id,
      scroll: { x: true }
    }
  ))));
};
var ExportFile_default = ExportFile;
