// LicenseType selon les modèles backend (marketplace/models.go)
export type LicenseType =
  | 'basic'
  | 'premium'
  | 'exclusive'
  | 'standard'
  | 'commercial';
// Note: Le handler utilise 'standard' | 'exclusive' | 'commercial' mais les modèles utilisent 'basic' | 'premium' | 'exclusive'
// On suit les modèles qui sont la source de vérité

export type ProductStatus = 'draft' | 'active' | 'archived';
export type ProductType = 'track' | 'pack' | 'service';

export interface ProductLicense {
  id: string;
  name: string;
  price: number;
  features: string[];
  isPopular?: boolean;
}

export interface Review {
  id: string;
  username: string;
  avatar: string;
  rating: number;
  comment: string;
  date: string;
}

export interface Product {
  id: string;
  seller_id: string;
  title: string;
  description: string;
  price: number;
  currency: string;
  status: ProductStatus;
  product_type: ProductType;
  track_id?: string;
  license_type?: LicenseType;
  created_at: string;
  updated_at: string;
  // Extended properties for UI (may be computed or aliases)
  type?: ProductType; // Alias for product_type
  coverUrl?: string; // Cover image URL
  isHot?: boolean; // Featured/popular flag
  author?: string; // Author/seller name
  // V2 Compatibility
  rating?: number;
  reviewCount?: number;
  features?: string[];
  licenses?: ProductLicense[];
  images?: string[];
  bpm?: string | number;
  key?: string;
  genre?: string;
  size?: string;
  reviews?: Review[];
}

export interface License {
  id: string;
  buyer_id: string;
  track_id: string;
  product_id: string;
  order_id: string;
  type: LicenseType;
  rights: string;
  downloads_left: number;
  created_at: string;
  expires_at?: string;
}

export interface OrderItem {
  id: string;
  order_id: string;
  product_id: string;
  price: number;
}

export interface Order {
  id: string;
  buyer_id: string;
  total_amount: number;
  currency: string;
  status: string;
  payment_intent?: string;
  items: OrderItem[];
  created_at: string;
  updated_at: string;
}

export interface CreateProductRequest {
  title: string;
  description: string;
  price: number;
  product_type: ProductType;
  track_id?: string;
  license_type?: LicenseType;
}

export interface CreateOrderRequest {
  items: { product_id: string }[];
}
