Spaces:
Runtime error
Runtime error
Greg
Claude Opus 4.7 (1M context)
feat(schedule): fit PDF in single page + use plantel name as title
413032b Download frontend/src/components/ScheduleViewerModal.tsx from Talosware/talos-access: direct link, hf CLI and curl.
- Browser
- Download file 3.84 kB
-
https://huggingface.co/spaces/Talosware/talos-access/resolve/main/frontend/src/components/ScheduleViewerModal.tsx
- Command line
-
hf download hf://spaces/Talosware/talos-access/frontend/src/components/ScheduleViewerModal.tsx
-
curl -L -o ScheduleViewerModal.tsx https://huggingface.co/spaces/Talosware/talos-access/resolve/main/frontend/src/components/ScheduleViewerModal.tsx
3.84 kB
| import { useState, useEffect } from 'react'; | |
| import { listSectionSchedules, type SectionSchedule } from '../services/sectionScheduleService'; | |
| import LoadingState from './LoadingState'; | |
| import ScheduleGrid from './ScheduleGrid'; | |
| import { useAuthStore } from '../store/authStore'; | |
| export interface ScheduleViewerModalProps { | |
| open: boolean; | |
| sectionId: number; | |
| sectionName: string; | |
| academicPeriod?: string | null; | |
| onClose: () => void; | |
| } | |
| export default function ScheduleViewerModal({ | |
| open, | |
| sectionId, | |
| sectionName, | |
| academicPeriod, | |
| onClose, | |
| }: ScheduleViewerModalProps) { | |
| const [items, setItems] = useState<SectionSchedule[]>([]); | |
| const [loading, setLoading] = useState(false); | |
| const organizationName = useAuthStore((s) => s.user?.organization_name || ''); | |
| useEffect(() => { | |
| if (!open) return; | |
| setLoading(true); | |
| listSectionSchedules(sectionId) | |
| .then(setItems) | |
| .catch(() => setItems([])) | |
| .finally(() => setLoading(false)); | |
| }, [open, sectionId]); | |
| if (!open) return null; | |
| const printDate = new Date().toLocaleDateString('es-VE', { | |
| day: '2-digit', | |
| month: 'long', | |
| year: 'numeric', | |
| }); | |
| return ( | |
| <div | |
| className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4 print-overlay" | |
| onClick={onClose} | |
| > | |
| <div | |
| className="bg-white rounded-2xl shadow-2xl max-w-5xl w-full max-h-[90vh] flex flex-col print-modal-box" | |
| onClick={(e) => e.stopPropagation()} | |
| > | |
| {/* Modal header — hidden in print */} | |
| <div className="no-print sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between rounded-t-2xl shrink-0"> | |
| <div> | |
| <h2 className="text-xl font-bold">Horario — {sectionName}</h2> | |
| {academicPeriod && ( | |
| <p className="text-sm text-gray-400 mt-0.5">{academicPeriod}</p> | |
| )} | |
| </div> | |
| <button | |
| onClick={onClose} | |
| className="text-gray-400 hover:text-gray-600 text-2xl leading-none" | |
| aria-label="Cerrar" | |
| > | |
| × | |
| </button> | |
| </div> | |
| {/* Printable grid area */} | |
| <div className="schedule-print-area p-4 overflow-auto flex-1"> | |
| {/* Print-only title: school name primary, section as subtitle */} | |
| <div className="hidden print:block text-center mb-2"> | |
| {organizationName && <h1 className="text-lg font-bold leading-tight">{organizationName}</h1>} | |
| <p className="text-sm text-gray-700 leading-tight"> | |
| Horario — {sectionName} | |
| {academicPeriod ? ` · ${academicPeriod}` : ''} | |
| </p> | |
| <p className="text-[10px] text-gray-400">Generado: {printDate}</p> | |
| </div> | |
| {loading ? ( | |
| <div className="flex items-center justify-center py-24"> | |
| <LoadingState /> | |
| </div> | |
| ) : items.length === 0 ? ( | |
| <p className="text-center text-gray-400 py-16">Sin bloques de horario registrados.</p> | |
| ) : ( | |
| <ScheduleGrid items={items} compact /> | |
| )} | |
| </div> | |
| {/* Modal footer — hidden in print */} | |
| <div className="no-print sticky bottom-0 bg-white border-t border-gray-200 px-6 py-4 flex items-center justify-end gap-3 rounded-b-2xl shrink-0"> | |
| <button | |
| onClick={onClose} | |
| className="px-4 py-2 rounded-lg border border-gray-300 text-gray-600 hover:bg-gray-50 transition text-sm" | |
| > | |
| Cerrar | |
| </button> | |
| <button | |
| onClick={() => window.print()} | |
| className="px-4 py-2 rounded-lg bg-blue-600 text-white hover:bg-blue-700 transition text-sm" | |
| > | |
| Descargar PDF | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| } | |