feat(ui): migrate to Tailwind UI and add result matrix tooling

This commit is contained in:
2026-03-03 22:54:06 -05:00
parent 1592434192
commit 87f52777c4
21 changed files with 1575 additions and 263 deletions
+61
View File
@@ -18,6 +18,13 @@ const {
createQuestionSetEmpty,
addQuestionToSet
} = require('../services/questionService');
const {
listResultModel,
createResultModel,
updateResultModel,
exportResultModelTemplate,
importResultModelExcel
} = require('../services/resultModelService');
const upload = multer();
const router = express.Router();
@@ -183,6 +190,60 @@ router.get('/question-sets/:id/questions', async (req, res, next) => {
}
});
router.get('/result-model', async (req, res, next) => {
try {
const rows = await listResultModel(req.tenantPool);
res.json(rows);
} catch (err) {
next(err);
}
});
router.post('/result-model', async (req, res, next) => {
try {
const { dimension, variable, subvariable, score_value, max_score, sort_order } = req.body;
if (!dimension || !variable || !subvariable) {
return res.status(400).json({ error: 'dimension, variable y subvariable requeridos' });
}
const result = await createResultModel(req.tenantPool, { dimension, variable, subvariable, score_value, max_score, sort_order });
res.json(result);
} catch (err) {
next(err);
}
});
router.patch('/result-model/:id', async (req, res, next) => {
try {
const { score_value, max_score, sort_order } = req.body;
await updateResultModel(req.tenantPool, req.params.id, { score_value, max_score, sort_order });
res.json({ ok: true });
} catch (err) {
next(err);
}
});
router.get('/result-model/template', async (req, res, next) => {
try {
const buffer = await exportResultModelTemplate();
res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
res.setHeader('Content-Disposition', 'attachment; filename=\"clima_result_model.xlsx\"');
res.send(buffer);
} catch (err) {
next(err);
}
});
router.post('/result-model/import', upload.single('file'), async (req, res, next) => {
try {
if (!req.file) return res.status(400).json({ error: 'Archivo requerido' });
const mode = req.body?.mode || 'replace';
const result = await importResultModelExcel(req.file.buffer, req.tenantPool, mode);
res.json(result);
} catch (err) {
next(err);
}
});
router.get('/dimensions', async (req, res, next) => {
try {
const rows = await listDimensions(req.tenantPool);