edicion de metadata dispositivos, UI/UX

This commit is contained in:
2025-09-26 18:20:36 -06:00
parent e10d8950d9
commit 9848bd46f1
4 changed files with 93 additions and 2 deletions

View File

@@ -162,4 +162,18 @@ router.get('/devices', async (_req, res) => {
}
});
router.patch('/devices/:id', async (req, res) => {
try {
const id = parseInt(String(req.params.id), 10);
if (!Number.isInteger(id) || id <= 0) return res.status(400).json({ ok: false, error: 'invalid_id' });
const { nombre, descripcion } = req.body || {};
const { rowCount } = await pool.query('UPDATE dispositivos SET nombre = $2, descripcion = $3, last_seen = NOW() WHERE id = $1', [id, nombre != null ? String(nombre) : null, descripcion != null ? String(descripcion) : null]);
if (rowCount === 0) return res.status(404).json({ ok: false, error: 'not_found' });
res.json({ ok: true });
} catch (e) {
console.error('PATCH /api/devices/:id error:', e?.message || e);
res.status(500).json({ ok: false, error: 'db_error' });
}
});
export default router;