Greg Claude Sonnet 4.6 commited on
Commit
33561bb
·
1 Parent(s): 2e3220b

chore(ui): swap native date inputs for DateInput across pages

Browse files

AttendanceReportsPage, LateArrivalsPage, TeacherAttendancePage: holiday-
blocking date inputs. HolidaysPage: allowHolidays + cache invalidation on
create/delete. EnrollmentsPage birthdate: allowHolidays. TeacherAttendancePage
Tarjetas button no longer disabled by schedule; title updated to informational.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

frontend/src/pages/AttendanceReportsPage.tsx CHANGED
@@ -6,6 +6,7 @@ import { BarChart3, Search, Download } from 'lucide-react';
6
  import { translateRole } from '../utils/roles';
7
  import HeatmapModal from '../components/HeatmapModal';
8
  import LoadingState from '../components/LoadingState';
 
9
 
10
  export default function AttendanceReportsPage() {
11
  const [items, setItems] = useState<Attendance[]>([]);
@@ -68,11 +69,11 @@ export default function AttendanceReportsPage() {
68
  </div>
69
  <div>
70
  <label className="block text-xs text-gray-500 mb-1">Desde</label>
71
- <input type="date" value={filters.date_from} onChange={(e) => { setFilters({ ...filters, date_from: e.target.value }); setPage(1); }} className="border border-gray-300 rounded-lg px-3 py-2" style={{ width: 'auto' }} />
72
  </div>
73
  <div>
74
  <label className="block text-xs text-gray-500 mb-1">Hasta</label>
75
- <input type="date" value={filters.date_to} onChange={(e) => { setFilters({ ...filters, date_to: e.target.value }); setPage(1); }} className="border border-gray-300 rounded-lg px-3 py-2" style={{ width: 'auto' }} />
76
  </div>
77
 
78
  <div>
 
6
  import { translateRole } from '../utils/roles';
7
  import HeatmapModal from '../components/HeatmapModal';
8
  import LoadingState from '../components/LoadingState';
9
+ import DateInput from '../components/DateInput';
10
 
11
  export default function AttendanceReportsPage() {
12
  const [items, setItems] = useState<Attendance[]>([]);
 
69
  </div>
70
  <div>
71
  <label className="block text-xs text-gray-500 mb-1">Desde</label>
72
+ <DateInput value={filters.date_from} onChange={(v) => { setFilters({ ...filters, date_from: v }); setPage(1); }} className="border border-gray-300 rounded-lg px-3 py-2" style={{ width: 'auto' }} />
73
  </div>
74
  <div>
75
  <label className="block text-xs text-gray-500 mb-1">Hasta</label>
76
+ <DateInput value={filters.date_to} onChange={(v) => { setFilters({ ...filters, date_to: v }); setPage(1); }} className="border border-gray-300 rounded-lg px-3 py-2" style={{ width: 'auto' }} />
77
  </div>
78
 
79
  <div>
frontend/src/pages/EnrollmentsPage.tsx CHANGED
@@ -9,6 +9,7 @@ import { Plus, Trash2, Search, BookOpen, ChevronLeft, ChevronRight, Users, Gradu
9
  import ScheduleModal from '../components/ScheduleModal';
10
  import BulkUploadModal from '../components/BulkUploadModal';
11
  import LoadingState from '../components/LoadingState';
 
12
 
13
  interface SectionTeacher {
14
  teacher_id: number;
@@ -771,7 +772,7 @@ export default function EnrollmentsPage() {
771
  </div>
772
  <div>
773
  <label className="block text-sm font-medium text-gray-700 mb-1">Fecha de Nacimiento</label>
774
- <input type="date" value={editForm.birthdate} onChange={(e) => setEditForm({ ...editForm, birthdate: e.target.value })}
775
  className="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm" />
776
  </div>
777
  <div>
 
9
  import ScheduleModal from '../components/ScheduleModal';
10
  import BulkUploadModal from '../components/BulkUploadModal';
11
  import LoadingState from '../components/LoadingState';
12
+ import DateInput from '../components/DateInput';
13
 
14
  interface SectionTeacher {
15
  teacher_id: number;
 
772
  </div>
773
  <div>
774
  <label className="block text-sm font-medium text-gray-700 mb-1">Fecha de Nacimiento</label>
775
+ <DateInput value={editForm.birthdate} onChange={(v) => setEditForm({ ...editForm, birthdate: v })} allowHolidays
776
  className="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm" />
777
  </div>
778
  <div>
frontend/src/pages/HolidaysPage.tsx CHANGED
@@ -2,6 +2,8 @@ import { useState, useEffect, FormEvent } from 'react';
2
  import api from '../services/api';
3
  import { Plus, Trash2 } from 'lucide-react';
4
  import LoadingState from '../components/LoadingState';
 
 
5
 
6
  interface Holiday {
7
  id: number;
@@ -59,6 +61,7 @@ export default function HolidaysPage() {
59
  const body: any = { name: form.name, start_date: form.start_date, type: form.type };
60
  if (form.end_date && form.end_date !== form.start_date) body.end_date = form.end_date;
61
  await api.post('/settings/holidays', body);
 
62
  setForm({ name: '', start_date: '', end_date: '', type: 'national' });
63
  setShowForm(false);
64
  load();
@@ -71,6 +74,7 @@ export default function HolidaysPage() {
71
  if (!confirm(`Eliminar "${name}"?`)) return;
72
  try {
73
  await api.delete(`/settings/holidays/${id}`);
 
74
  load();
75
  } catch { alert('Error al eliminar feriado'); }
76
  };
@@ -102,11 +106,11 @@ export default function HolidaysPage() {
102
  </div>
103
  <div>
104
  <label className="block text-sm font-medium text-gray-700 mb-1">Fecha inicio</label>
105
- <input type="date" value={form.start_date} onChange={(e) => setForm({ ...form, start_date: e.target.value })} required className="w-full border border-gray-300 rounded-lg px-3 py-2" />
106
  </div>
107
  <div>
108
  <label className="block text-sm font-medium text-gray-700 mb-1">Fecha fin <span className="text-gray-400 font-normal">(opcional)</span></label>
109
- <input type="date" value={form.end_date} onChange={(e) => setForm({ ...form, end_date: e.target.value })} className="w-full border border-gray-300 rounded-lg px-3 py-2" min={form.start_date || undefined} />
110
  <p className="text-xs text-gray-400 mt-1">Si se deja vacío, es un feriado de 1 día</p>
111
  </div>
112
  <div>
 
2
  import api from '../services/api';
3
  import { Plus, Trash2 } from 'lucide-react';
4
  import LoadingState from '../components/LoadingState';
5
+ import DateInput from '../components/DateInput';
6
+ import { invalidateHolidaysCache } from '../hooks/useHolidays';
7
 
8
  interface Holiday {
9
  id: number;
 
61
  const body: any = { name: form.name, start_date: form.start_date, type: form.type };
62
  if (form.end_date && form.end_date !== form.start_date) body.end_date = form.end_date;
63
  await api.post('/settings/holidays', body);
64
+ invalidateHolidaysCache();
65
  setForm({ name: '', start_date: '', end_date: '', type: 'national' });
66
  setShowForm(false);
67
  load();
 
74
  if (!confirm(`Eliminar "${name}"?`)) return;
75
  try {
76
  await api.delete(`/settings/holidays/${id}`);
77
+ invalidateHolidaysCache();
78
  load();
79
  } catch { alert('Error al eliminar feriado'); }
80
  };
 
106
  </div>
107
  <div>
108
  <label className="block text-sm font-medium text-gray-700 mb-1">Fecha inicio</label>
109
+ <DateInput value={form.start_date} onChange={(v) => setForm({ ...form, start_date: v })} required allowHolidays className="w-full border border-gray-300 rounded-lg px-3 py-2" />
110
  </div>
111
  <div>
112
  <label className="block text-sm font-medium text-gray-700 mb-1">Fecha fin <span className="text-gray-400 font-normal">(opcional)</span></label>
113
+ <DateInput value={form.end_date} onChange={(v) => setForm({ ...form, end_date: v })} allowHolidays className="w-full border border-gray-300 rounded-lg px-3 py-2" min={form.start_date || undefined} />
114
  <p className="text-xs text-gray-400 mt-1">Si se deja vacío, es un feriado de 1 día</p>
115
  </div>
116
  <div>
frontend/src/pages/LateArrivalsPage.tsx CHANGED
@@ -3,6 +3,7 @@ import api from '../services/api';
3
  import { Download } from 'lucide-react';
4
  import LoadingState from '../components/LoadingState';
5
  import { translateRole } from '../utils/roles';
 
6
 
7
  interface LateArrival {
8
  student_id: number;
@@ -76,11 +77,11 @@ export default function LateArrivalsPage() {
76
  </div>
77
  <div>
78
  <label className="block text-xs text-gray-500 mb-1">Desde</label>
79
- <input type="date" value={dateFrom} onChange={(e) => setDateFrom(e.target.value)} className="border border-gray-300 rounded-lg px-3 py-2 text-sm" />
80
  </div>
81
  <div>
82
  <label className="block text-xs text-gray-500 mb-1">Hasta</label>
83
- <input type="date" value={dateTo} onChange={(e) => setDateTo(e.target.value)} className="border border-gray-300 rounded-lg px-3 py-2 text-sm" />
84
  </div>
85
  <button onClick={downloadCSV}
86
  className="px-3 py-2 bg-emerald-600 text-white rounded-lg text-sm hover:bg-emerald-700 transition-colors inline-flex items-center justify-center gap-2">
 
3
  import { Download } from 'lucide-react';
4
  import LoadingState from '../components/LoadingState';
5
  import { translateRole } from '../utils/roles';
6
+ import DateInput from '../components/DateInput';
7
 
8
  interface LateArrival {
9
  student_id: number;
 
77
  </div>
78
  <div>
79
  <label className="block text-xs text-gray-500 mb-1">Desde</label>
80
+ <DateInput value={dateFrom} onChange={(v) => setDateFrom(v)} className="border border-gray-300 rounded-lg px-3 py-2 text-sm" />
81
  </div>
82
  <div>
83
  <label className="block text-xs text-gray-500 mb-1">Hasta</label>
84
+ <DateInput value={dateTo} onChange={(v) => setDateTo(v)} className="border border-gray-300 rounded-lg px-3 py-2 text-sm" />
85
  </div>
86
  <button onClick={downloadCSV}
87
  className="px-3 py-2 bg-emerald-600 text-white rounded-lg text-sm hover:bg-emerald-700 transition-colors inline-flex items-center justify-center gap-2">
frontend/src/pages/TeacherAttendancePage.tsx CHANGED
@@ -1,6 +1,7 @@
1
  import { useState, useEffect, useRef, useCallback } from 'react';
2
  import { useSearchParams } from 'react-router-dom';
3
  import LoadingState from '../components/LoadingState';
 
4
  import {
5
  getTeacherSections, getSectionStudents, submitSwipeAttendance, getAttendanceSummary, batchToggleAttendance,
6
  getStudentProfile, downloadAttendanceCSV,
@@ -249,9 +250,8 @@ export default function TeacherAttendancePage() {
249
  <div className="flex gap-2">
250
  <button className={`px-3 py-1.5 rounded-lg text-sm inline-flex items-center justify-center gap-2 transition-colors ${view === 'list' ? 'bg-blue-600 text-white hover:bg-blue-700 border-blue-600' : 'bg-gray-50 border border-gray-200 hover:bg-blue-50 hover:border-blue-300'}`} onClick={() => setView('list')}><List size={14} /> Lista</button>
251
  <button className={`px-3 py-1.5 rounded-lg text-sm inline-flex items-center justify-center gap-2 transition-colors ${view === 'swipe' ? 'bg-blue-600 text-white hover:bg-blue-700 border-blue-600' : 'bg-gray-50 border border-gray-200 hover:bg-blue-50 hover:border-blue-300'}`}
252
- disabled={!hasAnySchedule || !activeSchedule}
253
  onClick={() => { setPendingSwipe(new Map()); setView('swipe'); }}
254
- title={!hasAnySchedule ? 'Sin horario definido' : !activeSchedule ? 'Fuera del horario de clase' : ''}>
255
  <CreditCard size={14} /> Tarjetas
256
  </button>
257
  </div>
@@ -277,7 +277,7 @@ export default function TeacherAttendancePage() {
277
 
278
  {view === 'list' && (
279
  <div className="flex gap-2 items-end">
280
- <div><label className="block text-xs text-gray-500 mb-1">Fecha</label><input type="date" value={summaryDate} onChange={(e) => setSummaryDate(e.target.value)} className="w-full border border-gray-300 rounded-lg px-3 py-2 !w-auto !py-1.5" /></div>
281
  <button className="px-3 py-1.5 bg-gray-50 border border-gray-200 rounded-lg text-sm hover:bg-blue-50 hover:border-blue-300 transition-colors inline-flex items-center justify-center gap-2" onClick={handleExportCSV}><Download size={14} /> CSV</button>
282
  </div>
283
  )}
 
1
  import { useState, useEffect, useRef, useCallback } from 'react';
2
  import { useSearchParams } from 'react-router-dom';
3
  import LoadingState from '../components/LoadingState';
4
+ import DateInput from '../components/DateInput';
5
  import {
6
  getTeacherSections, getSectionStudents, submitSwipeAttendance, getAttendanceSummary, batchToggleAttendance,
7
  getStudentProfile, downloadAttendanceCSV,
 
250
  <div className="flex gap-2">
251
  <button className={`px-3 py-1.5 rounded-lg text-sm inline-flex items-center justify-center gap-2 transition-colors ${view === 'list' ? 'bg-blue-600 text-white hover:bg-blue-700 border-blue-600' : 'bg-gray-50 border border-gray-200 hover:bg-blue-50 hover:border-blue-300'}`} onClick={() => setView('list')}><List size={14} /> Lista</button>
252
  <button className={`px-3 py-1.5 rounded-lg text-sm inline-flex items-center justify-center gap-2 transition-colors ${view === 'swipe' ? 'bg-blue-600 text-white hover:bg-blue-700 border-blue-600' : 'bg-gray-50 border border-gray-200 hover:bg-blue-50 hover:border-blue-300'}`}
 
253
  onClick={() => { setPendingSwipe(new Map()); setView('swipe'); }}
254
+ title="Marcar asistencia (queda registrado en auditoría si es fuera de horario)">
255
  <CreditCard size={14} /> Tarjetas
256
  </button>
257
  </div>
 
277
 
278
  {view === 'list' && (
279
  <div className="flex gap-2 items-end">
280
+ <div><label className="block text-xs text-gray-500 mb-1">Fecha</label><DateInput value={summaryDate} onChange={(v) => setSummaryDate(v)} className="w-full border border-gray-300 rounded-lg px-3 py-2 !w-auto !py-1.5" /></div>
281
  <button className="px-3 py-1.5 bg-gray-50 border border-gray-200 rounded-lg text-sm hover:bg-blue-50 hover:border-blue-300 transition-colors inline-flex items-center justify-center gap-2" onClick={handleExportCSV}><Download size={14} /> CSV</button>
282
  </div>
283
  )}