import type { KbxReconcileResult } from '@kbx/contracts'
import { kbxApi } from '../../../http/generated/kbxApiClient'

export interface CreateReconcileExceptionsResponse {
  createdOrUpdatedCount: number
  skippedCount: number
}

export interface ReconcileFilter {
  reconcileType?: string | null
  status?: string | null
  keyword?: string | null
  page: number
  pageSize: number
}

export const reconcileApi = {
  search(filter: ReconcileFilter) {
    return kbxApi.request<KbxReconcileResult>('common.reconcile.search', { query: filter })
  },
  createExceptions(ids: string[]) {
    return kbxApi.request<CreateReconcileExceptionsResponse, { ids: string[] }>('common.reconcile.createExceptions', { body: { ids } })
  },
}
