diff --git a/backend/app/main.py b/backend/app/main.py index 18c667a..3bd5030 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -204,7 +204,7 @@ def send_completed_inspection_to_n8n(inspection, db): # No lanzamos excepción para no interrumpir el flujo normal -BACKEND_VERSION = "1.0.65" +BACKEND_VERSION = "1.0.66" app = FastAPI(title="Checklist Inteligente API", version=BACKEND_VERSION) # S3/MinIO configuration diff --git a/backend/app/schemas.py b/backend/app/schemas.py index 32946f4..7221741 100644 --- a/backend/app/schemas.py +++ b/backend/app/schemas.py @@ -200,7 +200,7 @@ class Inspection(InspectionBase): # Answer Schemas class AnswerBase(BaseModel): - answer_value: str + answer_value: Optional[str] = None # Opcional para permitir guardar solo análisis IA status: str = "ok" comment: Optional[str] = None is_flagged: bool = False diff --git a/frontend/package.json b/frontend/package.json index fe10d24..a030146 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "checklist-frontend", "private": true, - "version": "1.0.59", + "version": "1.0.60", "type": "module", "scripts": { "dev": "vite", diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 1a1327a..cee28bf 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -3441,7 +3441,10 @@ function InspectionModal({ checklist, user, onClose, onComplete }) { const question = questions.find(q => q.id === questionId) const answer = answers[questionId] - if (!answer?.value && answer?.value !== '') return // Don't save if no value + // Don't save if no value AND no observations AND no photos + if (!answer?.value && !answer?.observations && (!answer?.photos || answer.photos.length === 0)) { + return + } try { const token = localStorage.getItem('token') @@ -3452,20 +3455,22 @@ function InspectionModal({ checklist, user, onClose, onComplete }) { const config = question.options || {} const questionType = config.type || question.type - if (questionType === 'boolean' && config.choices) { - const selectedChoice = config.choices.find(c => c.value === answer.value) - status = selectedChoice?.status || 'ok' - } else if (questionType === 'single_choice' && config.choices) { - const selectedChoice = config.choices.find(c => c.value === answer.value) - status = selectedChoice?.status || 'ok' - } else if (questionType === 'pass_fail') { - // Compatibilidad hacia atrás - status = answer.value === 'pass' ? 'ok' : 'critical' - } else if (questionType === 'good_bad') { - // Compatibilidad hacia atrás - if (answer.value === 'good') status = 'ok' - else if (answer.value === 'regular') status = 'warning' - else if (answer.value === 'bad') status = 'critical' + if (answer?.value) { + if (questionType === 'boolean' && config.choices) { + const selectedChoice = config.choices.find(c => c.value === answer.value) + status = selectedChoice?.status || 'ok' + } else if (questionType === 'single_choice' && config.choices) { + const selectedChoice = config.choices.find(c => c.value === answer.value) + status = selectedChoice?.status || 'ok' + } else if (questionType === 'pass_fail') { + // Compatibilidad hacia atrás + status = answer.value === 'pass' ? 'ok' : 'critical' + } else if (questionType === 'good_bad') { + // Compatibilidad hacia atrás + if (answer.value === 'good') status = 'ok' + else if (answer.value === 'regular') status = 'warning' + else if (answer.value === 'bad') status = 'critical' + } } // Submit answer @@ -4278,7 +4283,7 @@ function InspectionModal({ checklist, user, onClose, onComplete }) { ) : ( <> 🤖 - Analizar con IA + Analizar Pregunta )}