import { apiGet, apiPost } from '@/lib/http'
import type {
  AdminAffiliateDashConfig,
  AdminAffiliateDashConfigResponse,
  AdminAffiliateDashMatchResult,
  AdminAffiliateDashProductListResult,
  AdminAffiliateDashWallet,
} from '@/types/admin'

export function fetchAdminAffiliateDashConfig() {
  return apiGet<AdminAffiliateDashConfigResponse>('/api/v1/admin/platform-config/affiliate-dash')
}

export function saveAdminAffiliateDashConfig(payload: AdminAffiliateDashConfig) {
  return apiPost<AdminAffiliateDashConfigResponse>(
    '/api/v1/admin/platform-config/affiliate-dash',
    payload,
  )
}

export function matchAdminAffiliateDashSku(productNo: string) {
  return apiPost<AdminAffiliateDashMatchResult>(
    '/api/v1/admin/platform-config/affiliate-dash/match',
    { productNo },
  )
}

export function fetchAdminAffiliateDashProducts(
  payload: {
    page?: number
    size?: number
  } = {},
) {
  return apiPost<AdminAffiliateDashProductListResult>(
    '/api/v1/admin/platform-config/affiliate-dash/products',
    payload,
  )
}

export function fetchAdminAffiliateDashWallet() {
  return apiPost<AdminAffiliateDashWallet>(
    '/api/v1/admin/platform-config/affiliate-dash/wallet',
    {},
  )
}
