import type { Dayjs } from 'dayjs';

import type {
  MarketingFullReductionActivityType,
  MarketingFullReductionChannel,
  MarketingFullReductionDisplayStatus,
  MarketingFullReductionGiftScopeType,
  MarketingFullReductionListItemDto,
  MarketingFullReductionMetricsDto,
  MarketingFullReductionScopeType,
  MarketingFullReductionSecondHalfDiscountType,
  MarketingFullReductionStatsDto,
  MarketingFullReductionStoreScopeMode,
} from '#/api/marketing';
import type { ProductCategoryDto, ProductPickerItemDto } from '#/api/product';

/**
 * 文件职责：满减活动页面类型定义。
 */

/** 列表筛选表单。 */
export interface FullReductionFilterForm {
  activityType: '' | MarketingFullReductionActivityType;
  status: '' | MarketingFullReductionDisplayStatus;
}

/** 商品范围表单。 */
export interface FullReductionScopeForm {
  categoryIds: string[];
  productIds: string[];
  scopeType: MarketingFullReductionScopeType;
}

/** 满减阶梯表单。 */
export interface FullReductionTierForm {
  meetAmount: null | number;
  reduceAmount: null | number;
}

/** 满赠规则表单。 */
export interface FullReductionGiftRuleForm {
  applicableScope: FullReductionScopeForm;
  buyQuantity: null | number;
  giftQuantity: null | number;
  giftScope: FullReductionScopeForm;
  giftScopeType: MarketingFullReductionGiftScopeType;
}

/** 第二份半价规则表单。 */
export interface FullReductionSecondHalfRuleForm {
  applicableScope: FullReductionScopeForm;
  discountType: MarketingFullReductionSecondHalfDiscountType;
}

/** 满减编辑抽屉表单。 */
export interface FullReductionEditorForm {
  activityType: MarketingFullReductionActivityType;
  channels: MarketingFullReductionChannel[];
  description: string;
  id: string;
  giftRule: FullReductionGiftRuleForm;
  metrics: MarketingFullReductionMetricsDto;
  name: string;
  reduceTiers: FullReductionTierForm[];
  scopeStoreId: string;
  secondHalfRule: FullReductionSecondHalfRuleForm;
  stackWithCoupon: boolean;
  storeIds: string[];
  storeScopeMode: MarketingFullReductionStoreScopeMode;
  validDateRange: [Dayjs, Dayjs] | null;
}

/** 列表卡片视图模型。 */
export type FullReductionCardViewModel = MarketingFullReductionListItemDto;

/** 统计视图模型。 */
export type FullReductionStatsViewModel = MarketingFullReductionStatsDto;

/** 二级抽屉选择目标。 */
export type FullReductionPickerTarget =
  | 'giftApplicable'
  | 'giftScope'
  | 'secondHalfApplicable';

/** 二级抽屉选择模式。 */
export type FullReductionPickerMode = 'category' | 'product';

/** 二级抽屉分类项。 */
export type FullReductionPickerCategoryItem = ProductCategoryDto;

/** 二级抽屉商品项。 */
export type FullReductionPickerProductItem = ProductPickerItemDto;
