import type { ProductKind, ProductStatus } from '#/api/product';
/**
 * 文件职责：商品列表页面常量配置。
 * 1. 提供筛选选项、默认状态、批量动作定义。
 * 2. 统一维护编辑/快速编辑/沽清表单默认值。
 */
import type {
  ProductBatchAction,
  ProductEditorFormState,
  ProductFilterState,
  ProductQuickEditFormState,
  ProductSoldoutFormState,
  ProductStatusMeta,
  ProductViewMode,
} from '#/views/product/list/types';

/** 分页尺寸选项。 */
export const PAGE_SIZE_OPTIONS = ['12', '24', '48'];

/** 视图模式切换选项。 */
export const PRODUCT_VIEW_OPTIONS: Array<{
  label: string;
  value: ProductViewMode;
}> = [
  { label: '卡片', value: 'card' },
  { label: '列表', value: 'list' },
];

/** 商品状态筛选。 */
export const PRODUCT_STATUS_OPTIONS: Array<{
  label: string;
  value: '' | ProductStatus;
}> = [
  { label: '全部状态', value: '' },
  { label: '在售', value: 'on_sale' },
  { label: '下架', value: 'off_shelf' },
  { label: '售罄', value: 'sold_out' },
];

/** 商品类型筛选。 */
export const PRODUCT_KIND_OPTIONS: Array<{
  label: string;
  value: '' | ProductKind;
}> = [
  { label: '全部类型', value: '' },
  { label: '单品', value: 'single' },
  { label: '套餐', value: 'combo' },
];

/** 商品状态展示映射。 */
export const PRODUCT_STATUS_META_MAP: Record<ProductStatus, ProductStatusMeta> =
  {
    on_sale: {
      label: '在售',
      color: '#52c41a',
      badgeClass: 'status-on-sale',
    },
    off_shelf: {
      label: '下架',
      color: '#9ca3af',
      badgeClass: 'status-off-shelf',
    },
    sold_out: {
      label: '售罄',
      color: '#ef4444',
      badgeClass: 'status-sold-out',
    },
  };

/** 默认筛选状态。 */
export const DEFAULT_FILTER_STATE: ProductFilterState = {
  categoryId: '',
  keyword: '',
  status: '',
  kind: '',
  page: 1,
  pageSize: 12,
};

/** 默认编辑表单。 */
export const DEFAULT_EDITOR_FORM: ProductEditorFormState = {
  id: '',
  name: '',
  subtitle: '',
  description: '',
  comboGroups: [],
  imageUrls: [],
  categoryId: '',
  kind: 'single',
  price: 0,
  originalPrice: null,
  stock: 0,
  tagsText: '',
  status: 'off_shelf',
  shelfMode: 'draft',
  timedOnShelfAt: '',
};

/** 默认快速编辑表单。 */
export const DEFAULT_QUICK_EDIT_FORM: ProductQuickEditFormState = {
  id: '',
  price: 0,
  originalPrice: null,
  stock: 0,
  isOnSale: false,
};

/** 默认沽清表单。 */
export const DEFAULT_SOLDOUT_FORM: ProductSoldoutFormState = {
  mode: 'today',
  remainStock: 0,
  reason: '',
  recoverAt: '',
  syncToPlatform: true,
  notifyManager: false,
};

/** 批量操作选项。 */
export const PRODUCT_BATCH_ACTION_OPTIONS: Array<{
  label: string;
  value: ProductBatchAction;
}> = [
  { label: '批量上架', value: 'batch_on' },
  { label: '批量下架', value: 'batch_off' },
  { label: '批量沽清', value: 'batch_soldout' },
  { label: '批量删除', value: 'batch_delete' },
];
