/**
 * Dummy Coupons Report Data
 * Structure matches /woonoow/v1/analytics/coupons API response
 */

export interface CouponsOverview {
  total_discount: number;
  coupons_used: number;
  revenue_with_coupons: number;
  avg_discount_per_order: number;
  change_percent: number;
}

export interface CouponPerformance {
  id: number;
  code: string;
  type: 'percent' | 'fixed_cart' | 'fixed_product';
  amount: number;
  uses: number;
  discount_amount: number;
  revenue_generated: number;
  roi: number;
  usage_limit: number | null;
  expiry_date: string | null;
}

export interface CouponUsageData {
  date: string;
  uses: number;
  discount: number;
  revenue: number;
}

export interface CouponsData {
  overview: CouponsOverview;
  coupons: CouponPerformance[];
  usage_chart: CouponUsageData[];
}

// Generate 30 days of coupon usage data
const generateUsageData = (): CouponUsageData[] => {
  const data: CouponUsageData[] = [];
  const today = new Date();
  
  for (let i = 29; i >= 0; i--) {
    const date = new Date(today);
    date.setDate(date.getDate() - i);
    
    const uses = Math.floor(Math.random() * 30);
    const discount = uses * (50000 + Math.random() * 150000);
    const revenue = discount * (4 + Math.random() * 3);
    
    data.push({
      date: date.toISOString().split('T')[0],
      uses,
      discount: Math.round(discount),
      revenue: Math.round(revenue),
    });
  }
  
  return data;
};

export const DUMMY_COUPONS_DATA: CouponsData = {
  overview: {
    total_discount: 28450000,
    coupons_used: 342,
    revenue_with_coupons: 186500000,
    avg_discount_per_order: 83187,
    change_percent: 8.5,
  },
  coupons: [
    {
      id: 1,
      code: 'WELCOME10',
      type: 'percent',
      amount: 10,
      uses: 86,
      discount_amount: 8600000,
      revenue_generated: 52400000,
      roi: 6.1,
      usage_limit: null,
      expiry_date: null,
    },
    {
      id: 2,
      code: 'FLASH50K',
      type: 'fixed_cart',
      amount: 50000,
      uses: 64,
      discount_amount: 3200000,
      revenue_generated: 28800000,
      roi: 9.0,
      usage_limit: 100,
      expiry_date: '2025-12-31',
    },
    {
      id: 3,
      code: 'NEWYEAR2025',
      type: 'percent',
      amount: 15,
      uses: 52,
      discount_amount: 7800000,
      revenue_generated: 42600000,
      roi: 5.5,
      usage_limit: null,
      expiry_date: '2025-01-15',
    },
    {
      id: 4,
      code: 'FREESHIP',
      type: 'fixed_cart',
      amount: 25000,
      uses: 48,
      discount_amount: 1200000,
      revenue_generated: 18400000,
      roi: 15.3,
      usage_limit: null,
      expiry_date: null,
    },
    {
      id: 5,
      code: 'VIP20',
      type: 'percent',
      amount: 20,
      uses: 38,
      discount_amount: 4560000,
      revenue_generated: 22800000,
      roi: 5.0,
      usage_limit: 50,
      expiry_date: '2025-11-30',
    },
    {
      id: 6,
      code: 'BUNDLE100K',
      type: 'fixed_cart',
      amount: 100000,
      uses: 28,
      discount_amount: 2800000,
      revenue_generated: 16800000,
      roi: 6.0,
      usage_limit: 30,
      expiry_date: '2025-11-15',
    },
    {
      id: 7,
      code: 'STUDENT15',
      type: 'percent',
      amount: 15,
      uses: 26,
      discount_amount: 2340000,
      revenue_generated: 14200000,
      roi: 6.1,
      usage_limit: null,
      expiry_date: null,
    },
  ],
  usage_chart: generateUsageData(),
};
