Actualziacion de analisis de ia con las imagenes y se agrega el campo de cod operario en el front y en el back
This commit is contained in:
@@ -3088,14 +3088,25 @@ function InspectionModal({ checklist, user, onClose, onComplete }) {
|
||||
formData.append('file', file)
|
||||
formData.append('question_id', question.id.toString())
|
||||
|
||||
console.log('📤 DATOS ENVIADOS AL BACKEND:')
|
||||
console.log(' - question_id:', question.id)
|
||||
console.log(' - question.text:', question.text)
|
||||
console.log(' - question.ai_prompt:', question.ai_prompt || 'NO TIENE')
|
||||
|
||||
// Include inspection_id for vehicle context
|
||||
if (inspectionId) {
|
||||
formData.append('inspection_id', inspectionId.toString())
|
||||
console.log(' - inspection_id:', inspectionId)
|
||||
} else {
|
||||
console.log(' - inspection_id: NO ENVIADO')
|
||||
}
|
||||
|
||||
// Include custom prompt if available
|
||||
if (question.ai_prompt) {
|
||||
formData.append('custom_prompt', question.ai_prompt)
|
||||
console.log(' - custom_prompt ENVIADO:', question.ai_prompt)
|
||||
} else {
|
||||
console.log(' - custom_prompt: NO ENVIADO (pregunta no tiene ai_prompt)')
|
||||
}
|
||||
|
||||
const response = await fetch(`${API_URL}/api/analyze-image`, {
|
||||
@@ -3104,13 +3115,21 @@ function InspectionModal({ checklist, user, onClose, onComplete }) {
|
||||
body: formData
|
||||
})
|
||||
|
||||
console.log('📥 RESPUESTA DEL BACKEND:')
|
||||
console.log(' - Status:', response.status)
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json()
|
||||
console.log(' - Result completo:', JSON.stringify(result, null, 2))
|
||||
|
||||
// Check if AI analysis was successful
|
||||
if (result.success && result.analysis) {
|
||||
analyses.push(result)
|
||||
console.log('✅ Análisis IA:', result)
|
||||
console.log('✅ Análisis IA exitoso')
|
||||
console.log(' - Provider:', result.provider)
|
||||
console.log(' - Model:', result.model)
|
||||
console.log(' - Status:', result.analysis.status)
|
||||
console.log(' - Observations:', result.analysis.observations)
|
||||
} else {
|
||||
console.warn('⚠️ Error en análisis IA:', result.error || result.message)
|
||||
// Show user-friendly error
|
||||
@@ -3119,7 +3138,8 @@ function InspectionModal({ checklist, user, onClose, onComplete }) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.warn('⚠️ Error HTTP en análisis IA:', response.status, await response.text())
|
||||
const errorText = await response.text()
|
||||
console.warn('⚠️ Error HTTP en análisis IA:', response.status, errorText)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3703,6 +3723,7 @@ function UsersTab({ user }) {
|
||||
username: '',
|
||||
email: '',
|
||||
password: '',
|
||||
employee_code: '',
|
||||
role: 'mechanic'
|
||||
})
|
||||
|
||||
@@ -3746,7 +3767,7 @@ function UsersTab({ user }) {
|
||||
|
||||
if (response.ok) {
|
||||
setShowCreateForm(false)
|
||||
setFormData({ username: '', email: '', password: '', role: 'mechanic' })
|
||||
setFormData({ username: '', email: '', password: '', employee_code: '', role: 'mechanic' })
|
||||
loadUsers()
|
||||
} else {
|
||||
const error = await response.json()
|
||||
@@ -3872,6 +3893,9 @@ function UsersTab({ user }) {
|
||||
<div>
|
||||
<h3 className="font-semibold text-gray-800">{u.username}</h3>
|
||||
<p className="text-sm text-gray-500">{u.email}</p>
|
||||
{u.employee_code && (
|
||||
<p className="text-xs text-gray-400 mt-0.5">Nro Operario: {u.employee_code}</p>
|
||||
)}
|
||||
<div className="flex gap-2 mt-1">
|
||||
<span className={`text-xs px-2 py-1 rounded ${
|
||||
u.role === 'admin'
|
||||
@@ -3960,6 +3984,19 @@ function UsersTab({ user }) {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||
Nro Operario <span className="text-gray-400 text-xs">(opcional)</span>
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={formData.employee_code || ''}
|
||||
onChange={(e) => setFormData({...formData, employee_code: e.target.value})}
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
|
||||
placeholder="Código de operario"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||
Contraseña
|
||||
@@ -3993,7 +4030,7 @@ function UsersTab({ user }) {
|
||||
type="button"
|
||||
onClick={() => {
|
||||
setShowCreateForm(false)
|
||||
setFormData({ username: '', email: '', password: '', role: 'mechanic' })
|
||||
setFormData({ username: '', email: '', password: '', employee_code: '', role: 'mechanic' })
|
||||
}}
|
||||
className="flex-1 px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 transition"
|
||||
>
|
||||
@@ -4021,6 +4058,7 @@ function UsersTab({ user }) {
|
||||
const updates = {
|
||||
username: editingUser.username,
|
||||
email: editingUser.email,
|
||||
employee_code: editingUser.employee_code,
|
||||
role: editingUser.role
|
||||
}
|
||||
handleUpdateUser(editingUser.id, updates)
|
||||
@@ -4051,6 +4089,19 @@ function UsersTab({ user }) {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||
Nro Operario <span className="text-gray-400 text-xs">(opcional)</span>
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={editingUser.employee_code || ''}
|
||||
onChange={(e) => setEditingUser({...editingUser, employee_code: e.target.value})}
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
|
||||
placeholder="Código de operario"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||
Rol
|
||||
|
||||
Reference in New Issue
Block a user