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/plus/orderList/components/FilterList.tsx
var FilterList_exports = {};
__export(FilterList_exports, {
  default: () => FilterList_default
});
module.exports = __toCommonJS(FilterList_exports);
var import_react = __toESM(require("react"));
var import_materials = require("@pisell/materials");
var import_antd = require("antd");
var import_dayjs = __toESM(require("dayjs"));
var { useContainerContext } = import_materials.PisellDataSourceContainer;
var FilterList = ({ locales, valueType, setValueType }) => {
  const form = import_antd.Form.useFormInstance();
  const { serverActions } = useContainerContext();
  const { list } = serverActions;
  const handleTodayClick = () => {
    const today = (0, import_dayjs.default)();
    const params = {
      orderDate: [today.startOf("day"), today.endOf("day")],
      payment_status: void 0
    };
    form.setFieldsValue(params);
    list.onSearch(params);
    setValueType(1);
  };
  const handleTodayToPayClick = () => {
    const today = (0, import_dayjs.default)();
    const params = {
      orderDate: [today.startOf("day"), today.endOf("day")],
      payment_status: ["payment_processing", "unpaid"]
      // 默认需付款侧，也可改为其他待支付状态
    };
    form.setFieldsValue(params);
    list.onSearch(params);
    setValueType(2);
  };
  const handleTodayRefundsClick = () => {
    const today = (0, import_dayjs.default)();
    const params = {
      orderDate: [today.startOf("day"), today.endOf("day")],
      payment_status: ["refunded", "partially_refunded"]
      // 默认设置为已退款
    };
    form.setFieldsValue(params);
    list.onSearch(params);
    setValueType(3);
  };
  const handleLast7DaysClick = () => {
    const today = (0, import_dayjs.default)();
    const sevenDaysAgo = today.subtract(6, "day");
    const params = {
      orderDate: [sevenDaysAgo.startOf("day"), today.endOf("day")],
      payment_status: void 0
    };
    form.setFieldsValue(params);
    list.onSearch(params);
    setValueType(4);
  };
  return /* @__PURE__ */ import_react.default.createElement("div", { style: { display: "flex", gap: "8px" } }, /* @__PURE__ */ import_react.default.createElement(
    import_antd.Button,
    {
      type: "primary",
      ghost: valueType !== 1,
      onClick: handleTodayClick
    },
    locales.getText("pisell2.orderList.filterButton.todayOrders")
  ), /* @__PURE__ */ import_react.default.createElement(
    import_antd.Button,
    {
      type: "primary",
      ghost: valueType !== 2,
      onClick: handleTodayToPayClick
    },
    locales.getText("pisell2.orderList.filterButton.todayPending")
  ), /* @__PURE__ */ import_react.default.createElement(
    import_antd.Button,
    {
      type: "primary",
      ghost: valueType !== 3,
      onClick: handleTodayRefundsClick
    },
    locales.getText("pisell2.orderList.filterButton.todayRefunds")
  ), /* @__PURE__ */ import_react.default.createElement(
    import_antd.Button,
    {
      type: "primary",
      ghost: valueType !== 4,
      onClick: handleLast7DaysClick
    },
    locales.getText("pisell2.orderList.filterButton.last7Days")
  ));
};
var FilterList_default = FilterList;
