import axios from 'axios'; import { API_CONFIG } from '../config/api.config'; const API_URL = API_CONFIG.baseURL; export interface Supplier { id: string; name: string; contact_person: string; phone: string; email: string; address: string; type: string; created_at: string; updated_at: string; } export const supplierService = { async getSuppliers(): Promise { const response = await axios.get(`${API_URL}/suppliers`); return response.data; }, async getSupplier(id: string): Promise { const response = await axios.get(`${API_URL}/suppliers/${id}`); return response.data; }, async getSupplierWithPurchases(id: string): Promise { const response = await axios.get(`${API_URL}/suppliers/${id}/purchases`); return response.data; }, async createSupplier(supplier: Omit): Promise { const response = await axios.post(`${API_URL}/suppliers`, supplier); return response.data; }, async updateSupplier(id: string, supplier: Partial): Promise { const response = await axios.patch(`${API_URL}/suppliers/${id}`, supplier); return response.data; }, async deleteSupplier(id: string): Promise { await axios.delete(`${API_URL}/suppliers/${id}`); }, };