From 34221c4726d21db27e2aa4693e857201ef5935e3 Mon Sep 17 00:00:00 2001 From: gitea Date: Thu, 27 Nov 2025 17:19:50 -0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Cambios=20implementados:=20?= =?UTF-8?q?=F0=9F=94=84=20Funci=C3=B3n=20getReadableAnswer()=20en=20Fronte?= =?UTF-8?q?nd:=20Convierte=20valores=20t=C3=A9cnicos=20a=20etiquetas=20leg?= =?UTF-8?q?ibles=20din=C3=A1micamente=20Lee=20la=20configuraci=C3=B3n=20qu?= =?UTF-8?q?estion.options=20(que=20t=C3=BA=20defines=20al=20crear=20pregun?= =?UTF-8?q?tas)=20Busca=20en=20el=20array=20choices=20la=20etiqueta=20corr?= =?UTF-8?q?espondiente=20al=20valor=20=F0=9F=93=8B=20Conversiones=20soport?= =?UTF-8?q?adas:=20Boolean:=20"yes"=20=E2=86=92=20"S=C3=AD",=20"pass"=20?= =?UTF-8?q?=E2=86=92=20"Pasa",=20"good"=20=E2=86=92=20"Bueno"=20Single=20C?= =?UTF-8?q?hoice:=20"option1"=20=E2=86=92=20"Opci=C3=B3n=201",=20"excellen?= =?UTF-8?q?t"=20=E2=86=92=20"Excelente"=20Multiple=20Choice:=20"lights,wip?= =?UTF-8?q?ers"=20=E2=86=92=20"Luces,=20Limpiaparabrisas"=20Scale/Text/Num?= =?UTF-8?q?ber/Date/Time:=20Se=20muestran=20tal=20cual=20(ya=20son=20legib?= =?UTF-8?q?les)=20=F0=9F=8E=AF=20D=C3=B3nde=20se=20aplica:=20Modal=20de=20?= =?UTF-8?q?detalle=20de=20inspecci=C3=B3n=20al=20ver=20respuestas=20comple?= =?UTF-8?q?tadas=20Respeta=20las=20configuraciones=20din=C3=A1micas=20que?= =?UTF-8?q?=20defines=20en=20el=20editor=20de=20preguntas=20Funciona=20con?= =?UTF-8?q?=20todas=20las=20plantillas=20predefinidas=20y=20configuracione?= =?UTF-8?q?s=20personalizadas=20=E2=9A=99=EF=B8=8F=20Funcionamiento=20din?= =?UTF-8?q?=C3=A1mico:=20Como=20los=20tipos=20de=20pregunta=20son=20config?= =?UTF-8?q?urables=20por=20ti=20en=20el=20frontend,=20=20la=20funci=C3=B3n?= =?UTF-8?q?=20lee=20directamente=20de=20question.options.choices=20el=20ar?= =?UTF-8?q?ray=20que=20t=C3=BA=20configuraste,=20=20por=20lo=20que=20funci?= =?UTF-8?q?onar=C3=A1=20autom=C3=A1ticamente=20con=20cualquier=20configura?= =?UTF-8?q?ci=C3=B3n=20que=20crees.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Versiones actualizadas: Frontend: 1.0.76 - Backend: 1.0.77 Ahora tanto el PDF como el modal de inspecciones mostrarán las etiquetas legibles en lugar de los valores técnicos. --- frontend/package.json | 2 +- frontend/src/App.jsx | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 20cabf4..dc82bcf 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "checklist-frontend", "private": true, - "version": "1.0.75", + "version": "1.0.76", "type": "module", "scripts": { "dev": "vite", diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 586d9e5..80328d7 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -2969,6 +2969,39 @@ function InspectionDetailModal({ inspection, user, onClose, onUpdate }) { const [auditLogs, setAuditLogs] = useState([]) const [loadingAudit, setLoadingAudit] = useState(false) + // Función helper para convertir valores técnicos a etiquetas legibles + const getReadableAnswer = (answerValue, questionOptions) => { + if (!answerValue || !questionOptions) { + return answerValue || 'Sin respuesta' + } + + const config = questionOptions + const questionType = config.type || '' + + // Para tipos con choices (boolean, single_choice, multiple_choice) + if (['boolean', 'single_choice', 'multiple_choice'].includes(questionType) && config.choices) { + // Si es multiple_choice, puede tener varios valores separados por coma + if (questionType === 'multiple_choice' && answerValue.includes(',')) { + const values = answerValue.split(',') + const labels = values.map(val => { + val = val.trim() + const choice = config.choices.find(c => c.value === val) + return choice ? choice.label : val + }) + return labels.join(', ') + } else { + // Buscar la etiqueta correspondiente al valor + const choice = config.choices.find(c => c.value === answerValue) + if (choice) { + return choice.label + } + } + } + + // Para tipos scale, text, number, date, time - devolver el valor tal cual + return answerValue + } + useEffect(() => { const loadInspectionDetails = async () => { try { @@ -3316,7 +3349,7 @@ function InspectionDetailModal({ inspection, user, onClose, onUpdate }) { {question.type === 'pass_fail' ? ( getStatusBadge(answer.status) ) : ( - {answer.answer_value} + {getReadableAnswer(answer.answer_value, question.options)} )} {answer.is_flagged && ( 🚩 Señalado