/**
 * Promo code types — wraps Stripe Coupon + Promotion Code APIs.
 */

import { z } from 'zod';

export interface PromoCodeResponse {
  id: string;
  code: string;
  active: boolean;
  couponId: string | null;
  percentOff: number | null;
  amountOff: number | null;
  currency: string | null;
  duration: string | null;
  timesRedeemed: number;
  maxRedemptions: number | null;
  expiresAt: string | null;
  created: string;
  metadata: Record<string, string>;
}

export const CreatePromoSchema = z.object({
  code: z.string().min(1),
  percentOff: z.number().min(1).max(100).optional(),
  amountOff: z.number().int().min(1).optional(),
  currency: z.string().default('usd'),
  duration: z.enum(['once', 'repeating', 'forever']).default('once'),
  durationInMonths: z.number().int().min(1).optional(),
  maxRedemptions: z.number().int().min(1).optional(),
  expiresAt: z.string().optional(),
  createdBy: z.string().default('system'),
});

export const DeactivatePromoSchema = z.object({
  id: z.string().min(1),
});

export type CreatePromoInput = z.infer<typeof CreatePromoSchema>;
