const express = require('express'); const pool = require('../config/db'); const router = express.Router(); // Endpoint to receive client status router.post('/track-status', async (req, res) => { try { const { client_id, status } = req.body; const timestamp = new Date(); // Log request await pool.query("INSERT INTO client_logs (client_id, status) VALUES (?, ?)", [client_id, status]); // Update client last active time await pool.query("UPDATE clients SET last_active = ? WHERE id = ?", [timestamp, client_id]); res.json({ message: "Status logged successfully!" }); } catch (err) { res.status(500).json({ error: err.message }); } }); module.exports = router;