2025-08-22 21:55:03 -03:00
|
|
|
// src/apiService.ts
|
|
|
|
|
import axios from 'axios';
|
2025-08-25 10:25:54 -03:00
|
|
|
import type { ResumenProvincial, ProyeccionBancas, MunicipioSimple, TelegramaData, CatalogoItem } from './types/types';
|
2025-08-22 21:55:03 -03:00
|
|
|
|
2025-08-25 10:25:54 -03:00
|
|
|
const API_BASE_URL = 'http://localhost:5217/api';
|
2025-08-22 21:55:03 -03:00
|
|
|
|
|
|
|
|
const apiClient = axios.create({
|
|
|
|
|
baseURL: API_BASE_URL,
|
2025-08-25 10:25:54 -03:00
|
|
|
headers: { 'Content-Type': 'application/json' },
|
2025-08-22 21:55:03 -03:00
|
|
|
});
|
|
|
|
|
|
2025-08-25 10:25:54 -03:00
|
|
|
export const getResumenProvincial = async (): Promise<ResumenProvincial> => {
|
|
|
|
|
const response = await apiClient.get('/resultados/provincia/02');
|
|
|
|
|
return response.data;
|
2025-08-22 21:55:03 -03:00
|
|
|
};
|
|
|
|
|
|
2025-08-25 10:25:54 -03:00
|
|
|
export const getBancasPorSeccion = async (seccionId: string): Promise<ProyeccionBancas> => {
|
|
|
|
|
const response = await apiClient.get(`/resultados/bancas/${seccionId}`);
|
2025-08-22 21:55:03 -03:00
|
|
|
return response.data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2025-08-25 10:25:54 -03:00
|
|
|
* Obtiene la lista de Secciones Electorales desde la API.
|
2025-08-22 21:55:03 -03:00
|
|
|
*/
|
2025-08-25 10:25:54 -03:00
|
|
|
export const getSeccionesElectorales = async (): Promise<MunicipioSimple[]> => {
|
|
|
|
|
const response = await apiClient.get('/catalogos/secciones-electorales');
|
2025-08-22 21:55:03 -03:00
|
|
|
return response.data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2025-08-25 10:25:54 -03:00
|
|
|
* Obtiene los datos completos de un telegrama por su ID de mesa.
|
2025-08-22 21:55:03 -03:00
|
|
|
*/
|
2025-08-25 10:25:54 -03:00
|
|
|
export const getTelegramaPorId = async (mesaId: string): Promise<TelegramaData> => {
|
|
|
|
|
const response = await apiClient.get(`/telegramas/${mesaId}`);
|
2025-08-22 21:55:03 -03:00
|
|
|
return response.data;
|
|
|
|
|
};
|
|
|
|
|
|
2025-08-25 10:25:54 -03:00
|
|
|
export const getSecciones = async (): Promise<CatalogoItem[]> => {
|
|
|
|
|
const response = await apiClient.get('/catalogos/secciones');
|
|
|
|
|
return response.data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const getMunicipiosPorSeccion = async (seccionId: string): Promise<CatalogoItem[]> => {
|
|
|
|
|
const response = await apiClient.get(`/catalogos/municipios/${seccionId}`);
|
|
|
|
|
return response.data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const getCircuitosPorMunicipio = async (municipioId: string): Promise<CatalogoItem[]> => {
|
|
|
|
|
const response = await apiClient.get(`/catalogos/circuitos/${municipioId}`);
|
|
|
|
|
return response.data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const getEstablecimientosPorCircuito = async (circuitoId: string): Promise<CatalogoItem[]> => {
|
|
|
|
|
const response = await apiClient.get(`/catalogos/establecimientos/${circuitoId}`);
|
|
|
|
|
return response.data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const getMesasPorEstablecimiento = async (establecimientoId: string): Promise<CatalogoItem[]> => {
|
|
|
|
|
const response = await apiClient.get(`/catalogos/mesas/${establecimientoId}`);
|
|
|
|
|
return response.data;
|
2025-08-22 21:55:03 -03:00
|
|
|
};
|