feat: inicializacion de Help Desk segun estandar Telcotronics con bitacora de errores e integracion MCP
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const { isAuthenticated } = require('../middleware/auth');
|
||||
const Company = require('../models/Company');
|
||||
const User = require('../models/User');
|
||||
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
try {
|
||||
const company = await Company.findById(req.session.user.company_id);
|
||||
const userCount = await Company.countUsers(company.id);
|
||||
const ticketCount = await Company.countTickets(company.id);
|
||||
res.render('company/settings', { company, userCount, ticketCount });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
req.flash('error_msg', 'Error al cargar configuración');
|
||||
res.redirect('/');
|
||||
}
|
||||
});
|
||||
|
||||
router.post('/update', isAuthenticated, async (req, res) => {
|
||||
const { name } = req.body;
|
||||
try {
|
||||
if (name) {
|
||||
await Company.update(req.session.user.company_id, { name });
|
||||
}
|
||||
req.flash('success_msg', 'Empresa actualizada');
|
||||
res.redirect('/company');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
req.flash('error_msg', 'Error al actualizar');
|
||||
res.redirect('/company');
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user