Spaces:
Runtime error
Runtime error
Greg Claude Sonnet 4.6 commited on
Commit ·
ba082ae
1
Parent(s): f4ca6fd
feat(representative): add Ver horario button per child
Browse filesShown inline next to section name when section_id is available.
section_id already present in ChildAttendance type, no backend change needed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
frontend/src/pages/RepresentativeChildrenPage.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import { useState, useEffect } from 'react';
|
| 2 |
import { getMyChildren, ChildAttendance } from '../services/representativeService';
|
| 3 |
-
import { Clock, CheckCircle, ChevronDown, ChevronUp, Calendar, AlertTriangle, Building2 } from 'lucide-react';
|
|
|
|
| 4 |
|
| 5 |
const fmtTime = (t: string | null) =>
|
| 6 |
t ? new Date(t).toLocaleTimeString('es-VE', { hour: '2-digit', minute: '2-digit' }) : '';
|
|
@@ -24,6 +25,9 @@ export default function RepresentativeChildrenPage() {
|
|
| 24 |
const [loading, setLoading] = useState(true);
|
| 25 |
const [expanded, setExpanded] = useState<number | null>(null);
|
| 26 |
|
|
|
|
|
|
|
|
|
|
| 27 |
useEffect(() => {
|
| 28 |
getMyChildren()
|
| 29 |
.then(setChildren)
|
|
@@ -62,9 +66,23 @@ export default function RepresentativeChildrenPage() {
|
|
| 62 |
<h2 className="text-lg font-semibold">
|
| 63 |
{child.name} {child.lastname}
|
| 64 |
</h2>
|
| 65 |
-
<
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
</div>
|
| 69 |
</div>
|
| 70 |
<button
|
|
@@ -146,6 +164,15 @@ export default function RepresentativeChildrenPage() {
|
|
| 146 |
</div>
|
| 147 |
))}
|
| 148 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
</div>
|
| 150 |
);
|
| 151 |
}
|
|
|
|
| 1 |
import { useState, useEffect } from 'react';
|
| 2 |
import { getMyChildren, ChildAttendance } from '../services/representativeService';
|
| 3 |
+
import { Clock, CheckCircle, ChevronDown, ChevronUp, Calendar, AlertTriangle, Building2, CalendarDays } from 'lucide-react';
|
| 4 |
+
import ScheduleViewerModal from '../components/ScheduleViewerModal';
|
| 5 |
|
| 6 |
const fmtTime = (t: string | null) =>
|
| 7 |
t ? new Date(t).toLocaleTimeString('es-VE', { hour: '2-digit', minute: '2-digit' }) : '';
|
|
|
|
| 25 |
const [loading, setLoading] = useState(true);
|
| 26 |
const [expanded, setExpanded] = useState<number | null>(null);
|
| 27 |
|
| 28 |
+
const [scheduleSectionId, setScheduleSectionId] = useState<number | null>(null);
|
| 29 |
+
const [scheduleSectionName, setScheduleSectionName] = useState<string>('');
|
| 30 |
+
|
| 31 |
useEffect(() => {
|
| 32 |
getMyChildren()
|
| 33 |
.then(setChildren)
|
|
|
|
| 66 |
<h2 className="text-lg font-semibold">
|
| 67 |
{child.name} {child.lastname}
|
| 68 |
</h2>
|
| 69 |
+
<div className="flex items-center gap-2 flex-wrap">
|
| 70 |
+
<p className="text-sm text-gray-500">
|
| 71 |
+
{child.section_name || 'Sin sección asignada'}
|
| 72 |
+
</p>
|
| 73 |
+
{child.section_id != null && child.section_id > 0 && (
|
| 74 |
+
<button
|
| 75 |
+
className="inline-flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800 font-medium"
|
| 76 |
+
onClick={() => {
|
| 77 |
+
setScheduleSectionId(child.section_id!);
|
| 78 |
+
setScheduleSectionName(child.section_name || '');
|
| 79 |
+
}}
|
| 80 |
+
title="Ver horario de la sección"
|
| 81 |
+
>
|
| 82 |
+
<CalendarDays size={12} /> Ver horario
|
| 83 |
+
</button>
|
| 84 |
+
)}
|
| 85 |
+
</div>
|
| 86 |
</div>
|
| 87 |
</div>
|
| 88 |
<button
|
|
|
|
| 164 |
</div>
|
| 165 |
))}
|
| 166 |
</div>
|
| 167 |
+
|
| 168 |
+
{scheduleSectionId !== null && (
|
| 169 |
+
<ScheduleViewerModal
|
| 170 |
+
open={true}
|
| 171 |
+
sectionId={scheduleSectionId}
|
| 172 |
+
sectionName={scheduleSectionName}
|
| 173 |
+
onClose={() => setScheduleSectionId(null)}
|
| 174 |
+
/>
|
| 175 |
+
)}
|
| 176 |
</div>
|
| 177 |
);
|
| 178 |
}
|