import { BasePaginationData, BaseRespData } from '@/types/api'
import axios from '../axios'
import {
  EditForm,
  SearchForm,
  WarehouseRuleSettingData,
  WarehouseRuleSpuItem,
} from '@/types/api/warehouse/warehouseRuleSetting'

export function getWarehouseRuleSettingListApi(
  data: SearchForm,
  page: number,
  pageSize: number,
) {
  return axios.post<never, BasePaginationData<WarehouseRuleSettingData>>(
    '/factory/sharedInventoryGroup/list-page',
    { ...data, page, pageSize },
  )
}

export function getQuerySpuApi(warehouseSpu: string, warehouseId: number | undefined) {
  return axios.post<never, BaseRespData<WarehouseRuleSpuItem>>(
    '/factory/sharedInventorySku/query-spu',
    { warehouseSpu, warehouseId },
  )
}

export function addSharedInventoryGroupApi(data: EditForm) {
  return axios.post<never, BaseRespData<void>>(
    '/factory/sharedInventoryGroup/add',
    data,
  )
}

export function updateSharedInventoryGroupApi(data: EditForm) {
  return axios.post<never, BaseRespData<void>>(
    '/factory/sharedInventoryGroup/update',
    data,
  )
}

export function getWarehouseRuleSettingDetailApi(id: number | undefined) {
  return axios.get<never, BaseRespData<EditForm>>(
    `/factory/sharedInventoryGroup/get`,
    {
      params: { id },
    },
  )
}
