Feat ERP 2
This commit is contained in:
17
frontend/admin-panel/src/services/calendarService.ts
Normal file
17
frontend/admin-panel/src/services/calendarService.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import api from './api';
|
||||
import type { BlackoutDate } from '../types/Calendar';
|
||||
|
||||
export const calendarService = {
|
||||
getByCompany: async (companyId: number, year: number) => {
|
||||
const res = await api.get<BlackoutDate[]>(`/calendar/${companyId}/${year}`);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
add: async (data: Partial<BlackoutDate>) => {
|
||||
await api.post('/calendar', data);
|
||||
},
|
||||
|
||||
delete: async (id: number) => {
|
||||
await api.delete(`/calendar/${id}`);
|
||||
}
|
||||
};
|
||||
22
frontend/admin-panel/src/services/companyService.ts
Normal file
22
frontend/admin-panel/src/services/companyService.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import api from './api';
|
||||
import type { Company } from '../types/Company';
|
||||
|
||||
export const companyService = {
|
||||
getAll: async (): Promise<Company[]> => {
|
||||
const response = await api.get<Company[]>('/companies');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
create: async (company: Partial<Company>): Promise<Company> => {
|
||||
const response = await api.post<Company>('/companies', company);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
update: async (id: number, company: Partial<Company>): Promise<void> => {
|
||||
await api.put(`/companies/${id}`, company);
|
||||
},
|
||||
|
||||
delete: async (id: number): Promise<void> => {
|
||||
await api.delete(`/companies/${id}`);
|
||||
}
|
||||
};
|
||||
25
frontend/admin-panel/src/services/financeService.ts
Normal file
25
frontend/admin-panel/src/services/financeService.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import api from './api';
|
||||
import type { ClientProfile, SettlementItem } from '../types/Finance';
|
||||
|
||||
export const financeService = {
|
||||
getClientStatus: async (clientId: number) => {
|
||||
const res = await api.get<ClientProfile>(`/finance/client/${clientId}`);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
updateProfile: async (clientId: number, profile: Partial<ClientProfile>) => {
|
||||
await api.post(`/finance/client/${clientId}`, profile);
|
||||
},
|
||||
|
||||
getDebtors: async () => {
|
||||
const res = await api.get<ClientProfile[]>('/finance/debtors');
|
||||
return res.data;
|
||||
},
|
||||
|
||||
getSettlementReport: async (from: string, to: string) => {
|
||||
const res = await api.get<SettlementItem[]>('/reports/inter-company-settlement', {
|
||||
params: { from, to }
|
||||
});
|
||||
return res.data;
|
||||
}
|
||||
};
|
||||
49
frontend/admin-panel/src/services/productService.ts
Normal file
49
frontend/admin-panel/src/services/productService.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import api from './api';
|
||||
import type { Product, ProductBundleComponent } from '../types/Product';
|
||||
|
||||
export const productService = {
|
||||
getAll: async (): Promise<Product[]> => {
|
||||
const response = await api.get<Product[]>('/products');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
getById: async (id: number): Promise<Product> => {
|
||||
const response = await api.get<Product>(`/products/${id}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
create: async (product: Partial<Product>): Promise<Product> => {
|
||||
const response = await api.post<Product>('/products', product);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
update: async (id: number, product: Partial<Product>): Promise<void> => {
|
||||
await api.put(`/products/${id}`, product);
|
||||
},
|
||||
|
||||
// --- GESTIÓN DE COMBOS (BUNDLES) ---
|
||||
|
||||
/**
|
||||
* Agrega un producto hijo a un combo padre.
|
||||
*/
|
||||
addComponentToBundle: async (bundleId: number, component: { childProductId: number; quantity: number; fixedAllocationAmount?: number }) => {
|
||||
await api.post(`/products/${bundleId}/components`, component);
|
||||
},
|
||||
|
||||
/**
|
||||
* Elimina un componente de un combo.
|
||||
*/
|
||||
removeComponentFromBundle: async (bundleId: number, childProductId: number) => {
|
||||
// Nota: El backend espera el ID del producto hijo, no el ID de la relación,
|
||||
// según nuestra implementación de 'RemoveComponentFromBundleAsync' en el repo.
|
||||
await api.delete(`/products/${bundleId}/components/${childProductId}`);
|
||||
},
|
||||
|
||||
/**
|
||||
* Obtiene la lista de componentes que forman un combo.
|
||||
*/
|
||||
getBundleComponents: async (bundleId: number): Promise<ProductBundleComponent[]> => {
|
||||
const response = await api.get<ProductBundleComponent[]>(`/products/${bundleId}/components`);
|
||||
return response.data;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user