refactor: creada organización de carpetas, instalado axios, implementado archivo .env con variables de entorno, implementado nuevo método calculateValueFunction en App.jsx

This commit is contained in:
Alexis
2026-03-24 09:57:51 +01:00
parent 351745d50f
commit 532fa9d5d2
14 changed files with 309 additions and 21 deletions
+3 -19
View File
@@ -1,5 +1,6 @@
import { useState } from 'react';
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts';
import { calculateValueFunction } from './services/docService';
function App() {
@@ -29,28 +30,11 @@ function App() {
references: currentReferences
};
console.log("Enviando JSON al backend:", payload);
try {
const response = await fetch('http://localhost:8000/api/criteria/doc/value-function', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
});
if (!response.ok) {
throw new Error(`Error del servidor: ${response.status}`);
}
const data = await response.json();
console.log("Respuesta del backend:", data);
const data = await calculateValueFunction(payload);
setResult(data);
} catch (error) {
console.error("Error al hacer la petición:", error);
alert("No se ha podido conectar con el backend.");
alert("No se ha podido conectar con el backend: " + error);
} finally {
setIsLoading(false);
}