// src/api/deal/types.ts

export type DealCardResponse = {
  id: number
  title: string
  description: string            // DB null → backend "" yapar
  price: number | null            // fiyat yoksa bilinçli null

  score: number
  status: "PENDING" | "ACTIVE" | "EXPIRED" | "REJECTED"
  saleType: "ONLINE" | "OFFLINE" | "CODE"
  affiliateType: "AFFILIATE" | "NON_AFFILIATE" | "USER_AFFILIATE"

  createdAt: string              // ISO string
  updatedAt: string
  /* ---------- YAYINLAYAN KULLANICI (profil için yeterli) ---------- */
  user: {
    id: number                   // 🔑 profil sayfası için
    username: string
    avatarUrl: string | null
  }

  /* ---------- SATICI (company + customCompany sadeleştirilmiş) ---------- */
  seller: {               
    name: string                 
    url:string|null
  }

  /* ---------- GÖRSELLER ---------- */
  imageUrl:string

  /* ---------- UX İÇİN TÜRETİLMİŞ ALANLAR ---------- */
  commentsCount: number
  userVote?: "UP" | "DOWN" | null
}

export type DealDetailResponse = {
  id: number
  title: string
  description: string

  url: string | null
  price: number | null
  score: number
  commentsCount: number

  status: "PENDING" | "ACTIVE" | "EXPIRED" | "REJECTED"
  saleType: "ONLINE" | "OFFLINE" | "CODE"
  affiliateType: "AFFILIATE" | "NON_AFFILIATE" | "USER_AFFILIATE"

  createdAt: string
  updatedAt: string

  user: {
    id: number
    username: string
    avatarUrl: string | null
  }

  seller: {               
    name: string                 
    url:string|null
  }

  images: {
    id: number
    imageUrl: string
    order: number
  }[]

  comments: {
    id: number
    text: string
    createdAt: string
    user: {
      id: number
      username: string
      avatarUrl: string | null
    }
  }[]
}



export type CreateDealRequest = {
  title: string
  description?: string
  price?: number
  imageUrl: string

  // online deal
  url?: string

  // seller (known or custom)
  sellerName: string
}

