All checks were successful
Optimized Build and Deploy / remote-build-and-deploy (push) Successful in 5m17s
66 lines
2.5 KiB
TypeScript
66 lines
2.5 KiB
TypeScript
import apiClient from '../apiClient';
|
|
import type { CanillaDto } from '../../models/dtos/Distribucion/CanillaDto';
|
|
import type { CreateCanillaDto } from '../../models/dtos/Distribucion/CreateCanillaDto';
|
|
import type { UpdateCanillaDto } from '../../models/dtos/Distribucion/UpdateCanillaDto';
|
|
import type { ToggleBajaCanillaDto } from '../../models/dtos/Distribucion/ToggleBajaCanillaDto';
|
|
import type { CanillaDropdownDto } from '../../models/dtos/Distribucion/CanillaDropdownDto';
|
|
|
|
|
|
const getAllCanillas = async (
|
|
nomApeFilter?: string,
|
|
legajoFilter?: number,
|
|
soloActivos?: boolean,
|
|
esAccionistaFilter?: boolean // Asegúrate que esté aquí
|
|
): Promise<CanillaDto[]> => {
|
|
const params: Record<string, string | number | boolean> = {};
|
|
if (nomApeFilter) params.nomApe = nomApeFilter;
|
|
if (legajoFilter !== undefined && legajoFilter !== null) params.legajo = legajoFilter;
|
|
if (soloActivos !== undefined) params.soloActivos = soloActivos;
|
|
if (esAccionistaFilter !== undefined) params.esAccionista = esAccionistaFilter;
|
|
|
|
const response = await apiClient.get<CanillaDto[]>('/canillas', { params });
|
|
return response.data;
|
|
};
|
|
|
|
const getAllDropdownCanillas = async (
|
|
soloActivos?: boolean,
|
|
esAccionistaFilter?: boolean // Asegúrate que esté aquí
|
|
): Promise<CanillaDropdownDto[]> => {
|
|
const params: Record<string, string | number | boolean> = {};
|
|
if (soloActivos !== undefined) params.soloActivos = soloActivos;
|
|
if (esAccionistaFilter !== undefined) params.esAccionista = esAccionistaFilter;
|
|
|
|
const response = await apiClient.get<CanillaDropdownDto[]>('/canillas/dropdown', { params });
|
|
return response.data;
|
|
};
|
|
|
|
const getCanillaById = async (id: number): Promise<CanillaDto> => {
|
|
const response = await apiClient.get<CanillaDto>(`/canillas/${id}`);
|
|
return response.data;
|
|
};
|
|
|
|
const createCanilla = async (data: CreateCanillaDto): Promise<CanillaDto> => {
|
|
const response = await apiClient.post<CanillaDto>('/canillas', data);
|
|
return response.data;
|
|
};
|
|
|
|
const updateCanilla = async (id: number, data: UpdateCanillaDto): Promise<void> => {
|
|
await apiClient.put(`/canillas/${id}`, data);
|
|
};
|
|
|
|
const toggleBajaCanilla = async (id: number, data: ToggleBajaCanillaDto): Promise<void> => {
|
|
// El backend espera el DTO en el cuerpo para este endpoint específico.
|
|
await apiClient.post(`/canillas/${id}/toggle-baja`, data);
|
|
};
|
|
|
|
|
|
const canillaService = {
|
|
getAllCanillas,
|
|
getAllDropdownCanillas,
|
|
getCanillaById,
|
|
createCanilla,
|
|
updateCanilla,
|
|
toggleBajaCanilla,
|
|
};
|
|
|
|
export default canillaService; |