24 lines
733 B
TypeScript
24 lines
733 B
TypeScript
import { api } from '@/lib/api'
|
|
import type { PaginatedResponse, SupplierResponse } from '@/types/api'
|
|
import type { PageParams } from './master'
|
|
|
|
export interface SupplierBody {
|
|
name: string
|
|
contactInfo?: string | null
|
|
isActive?: boolean
|
|
}
|
|
|
|
export const suppliers = {
|
|
list: (params?: PageParams) =>
|
|
api.get<PaginatedResponse<SupplierResponse>>('/suppliers', { params }).then(r => r.data),
|
|
|
|
get: (id: string) =>
|
|
api.get<SupplierResponse>(`/suppliers/${id}`).then(r => r.data),
|
|
|
|
create: (body: SupplierBody) =>
|
|
api.post<SupplierResponse>('/suppliers', body).then(r => r.data),
|
|
|
|
update: (id: string, body: Partial<SupplierBody>) =>
|
|
api.put<SupplierResponse>(`/suppliers/${id}`, body).then(r => r.data),
|
|
}
|