import { apiGet, apiPost } from '@/lib/http'
import type {
  AdminFulfillmentRoutingConfig,
  AdminFulfillmentRoutingPreviewResult,
} from '@/types/admin'

export function fetchAdminFulfillmentRoutingConfig() {
  return apiGet<AdminFulfillmentRoutingConfig>('/api/v1/admin/platform-config/fulfillment-routing')
}

export function saveAdminFulfillmentRoutingConfig(payload: Partial<AdminFulfillmentRoutingConfig>) {
  return apiPost<AdminFulfillmentRoutingConfig>(
    '/api/v1/admin/platform-config/fulfillment-routing',
    payload,
  )
}

export function previewAdminFulfillmentRouting(productName: string) {
  return apiPost<AdminFulfillmentRoutingPreviewResult>(
    '/api/v1/admin/platform-config/fulfillment-routing/preview',
    { productName },
  )
}
