Initial commit: ERP system with advance verification fixes
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
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<Supplier[]> {
|
||||
const response = await axios.get(`${API_URL}/suppliers`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async getSupplier(id: string): Promise<Supplier> {
|
||||
const response = await axios.get(`${API_URL}/suppliers/${id}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async getSupplierWithPurchases(id: string): Promise<any> {
|
||||
const response = await axios.get(`${API_URL}/suppliers/${id}/purchases`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async createSupplier(supplier: Omit<Supplier, 'id' | 'created_at' | 'updated_at'>): Promise<Supplier> {
|
||||
const response = await axios.post(`${API_URL}/suppliers`, supplier);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async updateSupplier(id: string, supplier: Partial<Supplier>): Promise<Supplier> {
|
||||
const response = await axios.patch(`${API_URL}/suppliers/${id}`, supplier);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async deleteSupplier(id: string): Promise<void> {
|
||||
await axios.delete(`${API_URL}/suppliers/${id}`);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user