SuiteCoffee/backup/lectura.html
msaldain f483058c2c Se pudo conectar satisfactoriamente a la base de datos tenantdb_1 y suitecoffee-db.
En ./services/app/

Se sirvierons los HTML de la carpeta /pages.

Se crearon los endpoints REST para crear y listar roles, usuarios, categorias, productos.
2025-08-14 23:37:38 +00:00

44 lines
1.3 KiB
HTML

<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Dashboard</title>
</head>
<body>
<h2>Mesas</h2>
<select id="mesasSelect"></select>
<h2>Productos</h2>
<select id="productosSelect"></select>
<h2>Categorías</h2>
<select id="categoriasSelect"></select>
<h2>Comandas</h2>
<select id="comandasSelect"></select>
<script>
async function cargarDatos(endpoint, selectId, mostrar) {
const res = await fetch(endpoint); // Usar endpoint relativo
const data = await res.json();
const select = document.getElementById(selectId);
data.forEach(item => {
const option = document.createElement('option');
option.value = item.id;
option.textContent = mostrar(item);
select.appendChild(option);
});
}
// Al cargar la página, cargamos los datos
window.onload = () => {
cargarDatos('api/obtenerMesas', 'mesasSelect', mesa => `Mesa ${mesa.numero}`);
cargarDatos('api/obtenerProductos', 'productosSelect', prod => `${prod.nombre} ($${prod.precio})`);
cargarDatos('api/obtenerCategorias', 'categoriasSelect', cat => cat.nombre);
cargarDatos('api/obtenerComandas', 'comandasSelect', com => `Comanda ${com.id} - Mesa ${com.mesa_id} - $${com.total}`);
};
</script>
</body>
</html>