now modified equipos

This commit is contained in:
2026-01-29 12:59:02 -06:00
parent 0ccd84f86a
commit 19118155bb
+29 -2
View File
@@ -22,6 +22,29 @@ export default function TableEquipos() {
});
}, []);
const toggleEquipo = async (id_equipo: number) => {
try {
await fetch(`${envConfig.apiUrl}/equipo/${id_equipo}/activo`, {
method: "PATCH",
});
setEquipos((prev) =>
prev.map((e) =>
e.id_equipo === id_equipo
? {
...e,
activo: {
data: [e.activo?.data?.[0] === 1 ? 0 : 1],
},
}
: e,
),
);
} catch (error) {
console.error("Error al cambiar estado del equipo", error);
}
};
if (loading) {
return <p>Cargando equipos...</p>;
}
@@ -61,8 +84,12 @@ export default function TableEquipos() {
style={{ display: "flex", alignItems: "center", gap: "5px" }}
>
<span>{isActivo ? "Sí" : "No"}</span>
<input type="checkbox" checked={isActivo} readOnly style={{height:"2.5rem"}}/>
<input
type="checkbox"
checked={isActivo}
style={{ height: "2.5rem" }}
onChange={() => toggleEquipo(eq.id_equipo)}
/>
</td>
</tr>
);