Spaces:
Runtime error
Runtime error
Greg Claude Sonnet 4.6 commited on
Commit ·
f4ca6fd
1
Parent(s): 099a820
feat(teacher): add Horario button on each section card
Browse filesOpens ScheduleViewerModal for the section. Uses CalendarDays icon,
secondary gray style, placed to the left of the Asistencia button.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
frontend/src/pages/TeacherSectionsPage.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
import { useState, useEffect } from 'react';
|
| 2 |
import { useNavigate } from 'react-router-dom';
|
| 3 |
import { getTeacherSections, type TeacherSection } from '../services/teacherService';
|
| 4 |
-
import { GraduationCap, Users as UsersIcon, CreditCard, Clock } from 'lucide-react';
|
| 5 |
import LoadingState from '../components/LoadingState';
|
|
|
|
| 6 |
|
| 7 |
const DAY_NAMES = ['Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado', 'Domingo'];
|
| 8 |
|
|
@@ -13,6 +14,10 @@ export default function TeacherSectionsPage() {
|
|
| 13 |
const [page, setPage] = useState(1);
|
| 14 |
const PER_PAGE = 10;
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
useEffect(() => {
|
| 17 |
setLoading(true);
|
| 18 |
getTeacherSections().then(setSections).catch(() => {}).finally(() => setLoading(false));
|
|
@@ -76,6 +81,18 @@ export default function TeacherSectionsPage() {
|
|
| 76 |
<UsersIcon size={14} />
|
| 77 |
<span>{sec.student_count} est.</span>
|
| 78 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
<button
|
| 80 |
className={`px-3 py-1.5 border rounded-lg text-sm transition-colors inline-flex items-center justify-center gap-2 ${activeBlock ? 'bg-emerald-500 text-white border-emerald-500 hover:bg-emerald-600' : 'bg-gray-50 border-gray-200 hover:bg-blue-50 hover:border-blue-300'}`}
|
| 81 |
onClick={(e) => { e.stopPropagation(); navigate(`/dashboard/teacher-attendance?section=${sec.id}&subject_id=${sec.subject_id || ''}&mode=swipe`); }}
|
|
@@ -95,6 +112,16 @@ export default function TeacherSectionsPage() {
|
|
| 95 |
<button disabled={currentPage >= totalPages} onClick={() => setPage(p => p + 1)} 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 disabled:opacity-30 inline-flex items-center justify-center gap-2">Siguiente</button>
|
| 96 |
</div>
|
| 97 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
</div>
|
| 99 |
);
|
| 100 |
}
|
|
|
|
| 1 |
import { useState, useEffect } from 'react';
|
| 2 |
import { useNavigate } from 'react-router-dom';
|
| 3 |
import { getTeacherSections, type TeacherSection } from '../services/teacherService';
|
| 4 |
+
import { GraduationCap, Users as UsersIcon, CreditCard, Clock, CalendarDays } from 'lucide-react';
|
| 5 |
import LoadingState from '../components/LoadingState';
|
| 6 |
+
import ScheduleViewerModal from '../components/ScheduleViewerModal';
|
| 7 |
|
| 8 |
const DAY_NAMES = ['Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado', 'Domingo'];
|
| 9 |
|
|
|
|
| 14 |
const [page, setPage] = useState(1);
|
| 15 |
const PER_PAGE = 10;
|
| 16 |
|
| 17 |
+
const [scheduleSectionId, setScheduleSectionId] = useState<number | null>(null);
|
| 18 |
+
const [scheduleSectionName, setScheduleSectionName] = useState<string>('');
|
| 19 |
+
const [scheduleAcademicPeriod, setScheduleAcademicPeriod] = useState<string | null>(null);
|
| 20 |
+
|
| 21 |
useEffect(() => {
|
| 22 |
setLoading(true);
|
| 23 |
getTeacherSections().then(setSections).catch(() => {}).finally(() => setLoading(false));
|
|
|
|
| 81 |
<UsersIcon size={14} />
|
| 82 |
<span>{sec.student_count} est.</span>
|
| 83 |
</div>
|
| 84 |
+
<button
|
| 85 |
+
className="px-3 py-1.5 border rounded-lg text-sm transition-colors inline-flex items-center justify-center gap-2 bg-gray-50 border-gray-200 hover:bg-gray-100 hover:border-gray-300"
|
| 86 |
+
onClick={(e) => {
|
| 87 |
+
e.stopPropagation();
|
| 88 |
+
setScheduleSectionId(sec.id);
|
| 89 |
+
setScheduleSectionName(sec.name);
|
| 90 |
+
setScheduleAcademicPeriod(sec.academic_period ?? null);
|
| 91 |
+
}}
|
| 92 |
+
title="Ver horario"
|
| 93 |
+
>
|
| 94 |
+
<CalendarDays size={14} /> Horario
|
| 95 |
+
</button>
|
| 96 |
<button
|
| 97 |
className={`px-3 py-1.5 border rounded-lg text-sm transition-colors inline-flex items-center justify-center gap-2 ${activeBlock ? 'bg-emerald-500 text-white border-emerald-500 hover:bg-emerald-600' : 'bg-gray-50 border-gray-200 hover:bg-blue-50 hover:border-blue-300'}`}
|
| 98 |
onClick={(e) => { e.stopPropagation(); navigate(`/dashboard/teacher-attendance?section=${sec.id}&subject_id=${sec.subject_id || ''}&mode=swipe`); }}
|
|
|
|
| 112 |
<button disabled={currentPage >= totalPages} onClick={() => setPage(p => p + 1)} 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 disabled:opacity-30 inline-flex items-center justify-center gap-2">Siguiente</button>
|
| 113 |
</div>
|
| 114 |
)}
|
| 115 |
+
|
| 116 |
+
{scheduleSectionId !== null && (
|
| 117 |
+
<ScheduleViewerModal
|
| 118 |
+
open={true}
|
| 119 |
+
sectionId={scheduleSectionId}
|
| 120 |
+
sectionName={scheduleSectionName}
|
| 121 |
+
academicPeriod={scheduleAcademicPeriod}
|
| 122 |
+
onClose={() => setScheduleSectionId(null)}
|
| 123 |
+
/>
|
| 124 |
+
)}
|
| 125 |
</div>
|
| 126 |
);
|
| 127 |
}
|