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