const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_useEngineContext = require("../../hooks/useEngineContext.js");
const require_index = require("../../utils/index.js");
const require_serve = require("./serve.js");
const require_locales = require("./locales.js");
const require_config = require("./config.js");
const require_Toolbar = require("./components/Toolbar.js");
const require_BatchActionBar = require("./components/BatchActionBar.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
require("./index.less");
//#region src/plus/orderList/index.tsx
const OrderList = (props) => {
	var _context$engine, _context$appHelper, _window, _utils$getApp;
	const { biz, style, className, __id } = props;
	const context = require_useEngineContext.default();
	_pisell_utils.locales.init(require_locales.default, (context === null || context === void 0 || (_context$engine = context.engine) === null || _context$engine === void 0 || (_context$engine = _context$engine.props) === null || _context$engine === void 0 ? void 0 : _context$engine.locale) || "en");
	const tableColumns = (0, react.useMemo)(() => require_config.getTableColumns(_pisell_utils.locales), [_pisell_utils.locales]);
	const utils = (context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {};
	require_index.request.setRequest(utils === null || utils === void 0 ? void 0 : utils.request);
	const useParams = (_window = window) === null || _window === void 0 || (_window = _window.app) === null || _window === void 0 || (_window = _window.history) === null || _window === void 0 ? void 0 : _window.useParams;
	const [selectedKeys, setSelectedKeys] = (0, react.useState)([]);
	const [selectedRows, setSelectedRows] = (0, react.useState)([]);
	const params = useParams === null || useParams === void 0 ? void 0 : useParams();
	const app = utils === null || utils === void 0 || (_utils$getApp = utils.getApp) === null || _utils$getApp === void 0 ? void 0 : _utils$getApp.call(utils);
	const extraParams = (0, react.useMemo)(() => {
		return { list: { business_code: biz || (params === null || params === void 0 ? void 0 : params.biz) } };
	}, [props.biz, params === null || params === void 0 ? void 0 : params.biz]);
	const tableConfig = (0, react.useMemo)(() => {
		return {
			columns: tableColumns,
			bordered: true,
			rowKey: "id",
			scroll: { x: "max-content" },
			size: "small",
			onRow: (record) => {
				return { onClick: () => {
					var _app$history;
					const pathname = encodeURIComponent((app === null || app === void 0 || (_app$history = app.history) === null || _app$history === void 0 || (_app$history = _app$history.instance) === null || _app$history === void 0 || (_app$history = _app$history.location) === null || _app$history === void 0 ? void 0 : _app$history.pathname) || "");
					app.history.push(`/order-detail?id=${record.id}&goback=${pathname}`);
				} };
			},
			rowSelection: {
				selectedRowKeys: selectedKeys,
				onChange: (selectedRowKeys, selectedRows) => {
					setSelectedKeys(selectedRowKeys);
					setSelectedRows(selectedRows);
				}
			}
		};
	}, [tableColumns, selectedKeys]);
	const batchActionBarConfig = (0, react.useMemo)(() => {
		return {
			locales: _pisell_utils.locales,
			selectedKeys,
			selectedRows,
			onClearSelection: () => {
				setSelectedKeys([]);
				setSelectedRows([]);
			}
		};
	}, [
		_pisell_utils.locales,
		selectedKeys,
		selectedRows
	]);
	const clearSelectedData = (0, react.useCallback)(() => {
		setSelectedKeys([]);
		setSelectedRows([]);
	}, []);
	return /* @__PURE__ */ react.default.createElement(_pisell_materials.Page, {
		style: { height: "100%" },
		key: extraParams.list.business_code
	}, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellDataSourceContainer, {
		dataSource: { key: "orderList" },
		actions: { list: require_serve.listApi },
		pagination: true,
		extraParams
	}, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellGridPro, {
		style: require_objectSpread2._objectSpread2({ height: "100vh" }, style),
		className
	}, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellGridPro.Header, { title: _pisell_utils.locales.getText("pisell2.orderList.title") }), /* @__PURE__ */ react.default.createElement(require_Toolbar.default, {
		clearSelectedData,
		__id,
		locales: _pisell_utils.locales
	}), /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellGridView, null, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellDataSourceContainer.Table, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, tableConfig), {}, { __id }))), /* @__PURE__ */ react.default.createElement(require_BatchActionBar.default, batchActionBarConfig), /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellGridPro.Footer, null, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellDataSourceContainer.Pagination, null)))));
};
//#endregion
exports.default = OrderList;
