// One typed client method for reference data (docs/11-BACKEND-PHASE1.md §6).
import { apiRequest, buildQuery } from "@/lib/api-client"
import { PagedResponse } from "@/types/common"
import { ReasonCode, ReasonCodeContext } from "@/types/stock"

export interface ListReasonCodesParams {
  context?: ReasonCodeContext
  page?: number
  pageSize?: number
  q?: string
}

export const reasonCodesApi = {
  list(context?: ReasonCodeContext, params: Omit<ListReasonCodesParams, "context"> = {}): Promise<PagedResponse<ReasonCode>> {
    return apiRequest<PagedResponse<ReasonCode>>(`/reason-codes${buildQuery({ context, ...params })}`)
  },
}
