import type { OptionItem, OrderAllFilterState } from '../../types';

import type {
  OrderAllChannelFilter,
  OrderAllPaymentFilter,
  OrderAllStatusFilter,
} from '#/api/order';

import { getTodayDateString } from './helpers';

export const STATUS_OPTIONS: OptionItem[] = [
  { label: '全部状态', value: 'all' },
  { label: '待接单', value: 'pending' },
  { label: '制作中', value: 'making' },
  { label: '配送中', value: 'delivering' },
  { label: '待取餐', value: 'pickup' },
  { label: '已完成', value: 'completed' },
  { label: '已取消', value: 'cancelled' },
  { label: '已退款', value: 'refunded' },
];

export const CHANNEL_OPTIONS: OptionItem[] = [
  { label: '全部渠道', value: 'all' },
  { label: '外卖', value: 'delivery' },
  { label: '自提', value: 'pickup' },
  { label: '堂食', value: 'dine_in' },
];

export const PAYMENT_OPTIONS: OptionItem[] = [
  { label: '全部支付', value: 'all' },
  { label: '微信支付', value: 'wechat' },
  { label: '支付宝', value: 'alipay' },
  { label: '余额支付', value: 'balance' },
  { label: '现金', value: 'cash' },
  { label: '刷卡', value: 'card' },
];

export function createDefaultFilters(): OrderAllFilterState {
  const today = getTodayDateString();
  return {
    status: 'all' as OrderAllStatusFilter,
    channel: 'all' as OrderAllChannelFilter,
    paymentMethod: 'all' as OrderAllPaymentFilter,
    keyword: '',
    startDate: today,
    endDate: today,
  };
}

export const DEFAULT_STATS = {
  totalOrders: 0,
  totalAmount: 0,
  averageAmount: 0,
  refundCount: 0,
};
