Corregir notificaicon check

This commit is contained in:
2025-11-25 08:43:54 -03:00
parent 093256382c
commit ad59152cce
5 changed files with 124 additions and 4 deletions

View File

@@ -908,6 +908,7 @@ function QuestionsManagerModal({ checklist, onClose }) {
allow_photos: true,
max_photos: 3,
requires_comment_on_fail: false,
send_notification: false,
parent_question_id: null,
show_if_answer: '',
ai_prompt: ''
@@ -966,6 +967,7 @@ function QuestionsManagerModal({ checklist, onClose }) {
allow_photos: true,
max_photos: 3,
requires_comment_on_fail: false,
send_notification: false,
parent_question_id: null,
show_if_answer: '',
ai_prompt: ''
@@ -1221,6 +1223,23 @@ function QuestionsManagerModal({ checklist, onClose }) {
</div>
</div>
<div className="bg-yellow-50 border border-yellow-200 rounded-lg p-4">
<div className="flex items-center gap-2">
<input
type="checkbox"
checked={formData.send_notification}
onChange={(e) => setFormData({ ...formData, send_notification: e.target.checked })}
className="w-4 h-4 text-yellow-600 border-gray-300 rounded focus:ring-yellow-500"
/>
<label className="text-sm font-medium text-gray-700">
🔔 Enviar notificación cuando se responda esta pregunta
</label>
</div>
<p className="text-xs text-gray-600 mt-2 ml-6">
Si activas esta opción, se enviará una notificación automática al administrador cada vez que un mecánico responda esta pregunta.
</p>
</div>
<button
type="submit"
className="w-full px-4 py-2 bg-purple-600 text-white rounded-lg hover:bg-purple-700 transition"
@@ -3472,12 +3491,14 @@ function ReportsTab({ user }) {
const [filters, setFilters] = useState({
date: '',
mechanicId: '',
checklistId: ''
checklistId: '',
vehiclePlate: ''
})
const [appliedFilters, setAppliedFilters] = useState({
date: '',
mechanicId: '',
checklistId: ''
checklistId: '',
vehiclePlate: ''
})
const loadMechanics = async () => {
@@ -3572,6 +3593,14 @@ function ReportsTab({ user }) {
data = filtered
console.log('After checklist filter:', data.length, 'items')
}
// Filtrar por matrícula en el frontend
if (filtersToApply.vehiclePlate) {
const filtered = data.filter(i =>
i.vehicle_plate && i.vehicle_plate.toLowerCase().includes(filtersToApply.vehiclePlate.toLowerCase())
)
data = filtered
console.log('After plate filter:', data.length, 'items')
}
setInspections(data)
} else {
console.error('Inspections request failed:', response.status)
@@ -3594,7 +3623,7 @@ function ReportsTab({ user }) {
// Cargar mecánicos y checklists primero
await Promise.all([loadMechanics(), loadChecklists()])
// Luego cargar datos sin filtros (filtros vacíos = todos los datos)
const emptyFilters = { date: '', mechanicId: '', checklistId: '' }
const emptyFilters = { date: '', mechanicId: '', checklistId: '', vehiclePlate: '' }
await Promise.all([loadDashboard(emptyFilters), loadInspections(emptyFilters)])
setLoading(false)
}
@@ -3614,7 +3643,7 @@ function ReportsTab({ user }) {
{/* Filtros */}
<div className="bg-white rounded-lg shadow p-4">
<h3 className="text-lg font-semibold mb-4">🔍 Filtros</h3>
<div className="grid grid-cols-1 md:grid-cols-4 gap-4">
<div className="grid grid-cols-1 md:grid-cols-5 gap-4">
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">
Fecha
@@ -3662,6 +3691,18 @@ function ReportsTab({ user }) {
))}
</select>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">
Matrícula
</label>
<input
type="text"
value={filters.vehiclePlate}
onChange={(e) => setFilters({...filters, vehiclePlate: e.target.value})}
placeholder="Ej: ABC123"
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500"
/>
</div>
<div className="flex items-end">
<button
onClick={applyFilters}