Spaces:
Runtime error
feat(schedule): fit PDF in single page + use plantel name as title
Browse filesBackend:
- /auth/me incluye organization_name desde Account; frontend lo persiste
en authStore para uso en todo el cliente.
Frontend:
- ScheduleGrid en modo compact (print) ahora oculta filas de horas
vacias (slots sin ningun bloque en dias visibles), reduciendo
significativamente el alto total. Tamanos chicos: min-h 40px,
text-xs, gap-1, time col 80px, padding ajustado.
- ScheduleViewerModal usa organization_name del authStore como H1
primario del PDF y la seccion + periodo como subtitulo.
- Print margin reducido de 0.5in a 0.35in para mas espacio util.
Resultado: horario tipico (8-9 horas de clase, 5 dias) ahora cabe en
una sola pagina letter landscape.
Nota operativa: usuarios con session persistida vieja necesitan
re-login para que organization_name aparezca en el authStore;
mientras tanto el titulo PDF cae al subtitulo solo (Horario --
seccion).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@@ -55,6 +55,7 @@ def me(current_user: User = Depends(get_current_user), db: Session = Depends(get
|
|
| 55 |
lastname=current_user.lastname,
|
| 56 |
role=current_user.role,
|
| 57 |
plan="",
|
|
|
|
| 58 |
self_checkin_enabled=bool(account.self_checkin_enabled) if account else False,
|
| 59 |
checkin_mode=account.checkin_mode or "manual" if account else "manual",
|
| 60 |
permissions=[p.permission for p in perms],
|
|
|
|
| 55 |
lastname=current_user.lastname,
|
| 56 |
role=current_user.role,
|
| 57 |
plan="",
|
| 58 |
+
organization_name=(account.organization_name or "") if account else "",
|
| 59 |
self_checkin_enabled=bool(account.self_checkin_enabled) if account else False,
|
| 60 |
checkin_mode=account.checkin_mode or "manual" if account else "manual",
|
| 61 |
permissions=[p.permission for p in perms],
|
|
@@ -21,6 +21,7 @@ class CurrentUserResponse(BaseModel):
|
|
| 21 |
lastname: str
|
| 22 |
role: str
|
| 23 |
plan: str
|
|
|
|
| 24 |
self_checkin_enabled: bool = False
|
| 25 |
checkin_mode: str = "manual"
|
| 26 |
permissions: list[str] = []
|
|
|
|
| 21 |
lastname: str
|
| 22 |
role: str
|
| 23 |
plan: str
|
| 24 |
+
organization_name: str = ""
|
| 25 |
self_checkin_enabled: bool = False
|
| 26 |
checkin_mode: str = "manual"
|
| 27 |
permissions: list[str] = []
|
|
@@ -41,26 +41,41 @@ export default function ScheduleGrid({ items, showWeekend = false, compact = fal
|
|
| 41 |
customSlots.sort((a, b) => a.entry.localeCompare(b.entry));
|
| 42 |
const allSlots = [...FIXED_SLOTS, ...customSlots];
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
const
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
return (
|
| 51 |
<div
|
| 52 |
-
className=
|
| 53 |
-
style={{ gridTemplateColumns: `
|
| 54 |
>
|
| 55 |
-
<div className={`${headerText} text-gray-400 font-medium self-end pb-
|
| 56 |
{visibleDays.map((d, i) => (
|
| 57 |
-
<div key={i} className={`${headerText} font-semibold text-gray-600 text-center pb-
|
| 58 |
{d.slice(0, 3)}
|
| 59 |
</div>
|
| 60 |
))}
|
| 61 |
-
{
|
| 62 |
<div key={rowIdx} className="contents">
|
| 63 |
-
<div className={`${slotText} text-gray-500 font-mono pt-1
|
| 64 |
{slot.entry}<br /><span className="text-gray-300">{slot.exit}</span>
|
| 65 |
</div>
|
| 66 |
{visibleDays.map((dayName, vIdx) => {
|
|
@@ -89,7 +104,7 @@ export default function ScheduleGrid({ items, showWeekend = false, compact = fal
|
|
| 89 |
>
|
| 90 |
<span className="font-mono">{block.entry_time}β{block.exit_time}</span>
|
| 91 |
{block.subject_name && (
|
| 92 |
-
<div className=
|
| 93 |
{block.subject_name}
|
| 94 |
{block.teacher_name ? ` β ${block.teacher_name}` : ''}
|
| 95 |
</div>
|
|
|
|
| 41 |
customSlots.sort((a, b) => a.entry.localeCompare(b.entry));
|
| 42 |
const allSlots = [...FIXED_SLOTS, ...customSlots];
|
| 43 |
|
| 44 |
+
// En compact (print), oculta filas de horas que no tienen ningΓΊn bloque en
|
| 45 |
+
// ningΓΊn dΓa visible. Reduce el alto total para que el PDF entre en 1 pΓ‘gina.
|
| 46 |
+
const slotsToShow = compact
|
| 47 |
+
? allSlots.filter((slot) =>
|
| 48 |
+
items.some(
|
| 49 |
+
(b) =>
|
| 50 |
+
b.entry_time === slot.entry &&
|
| 51 |
+
b.exit_time === slot.exit &&
|
| 52 |
+
visibleDays.includes(DAY_NAMES[b.day_of_week])
|
| 53 |
+
)
|
| 54 |
+
)
|
| 55 |
+
: allSlots;
|
| 56 |
+
|
| 57 |
+
const blockPadding = compact ? 'px-1.5 py-1' : 'px-4 py-3';
|
| 58 |
+
const blockText = compact ? 'text-xs' : 'text-base';
|
| 59 |
+
const headerText = compact ? 'text-xs' : 'text-base';
|
| 60 |
+
const slotText = compact ? 'text-xs' : 'text-base';
|
| 61 |
+
const minCellH = compact ? 'min-h-[40px]' : 'min-h-[90px]';
|
| 62 |
+
const gridGap = compact ? 'gap-1' : 'gap-3';
|
| 63 |
+
const timeColWidth = compact ? '80px' : '120px';
|
| 64 |
|
| 65 |
return (
|
| 66 |
<div
|
| 67 |
+
className={`grid ${gridGap}`}
|
| 68 |
+
style={{ gridTemplateColumns: `${timeColWidth} repeat(${visibleDays.length}, 1fr)` }}
|
| 69 |
>
|
| 70 |
+
<div className={`${headerText} text-gray-400 font-medium self-end pb-1 pl-1`}>Hora</div>
|
| 71 |
{visibleDays.map((d, i) => (
|
| 72 |
+
<div key={i} className={`${headerText} font-semibold text-gray-600 text-center pb-1 border-b-2 border-gray-200`}>
|
| 73 |
{d.slice(0, 3)}
|
| 74 |
</div>
|
| 75 |
))}
|
| 76 |
+
{slotsToShow.map((slot, rowIdx) => (
|
| 77 |
<div key={rowIdx} className="contents">
|
| 78 |
+
<div className={`${slotText} text-gray-500 font-mono pt-1 pr-1 text-right self-start ${rowIdx >= FIXED_SLOTS.length ? 'italic' : ''}`}>
|
| 79 |
{slot.entry}<br /><span className="text-gray-300">{slot.exit}</span>
|
| 80 |
</div>
|
| 81 |
{visibleDays.map((dayName, vIdx) => {
|
|
|
|
| 104 |
>
|
| 105 |
<span className="font-mono">{block.entry_time}β{block.exit_time}</span>
|
| 106 |
{block.subject_name && (
|
| 107 |
+
<div className={`${compact ? 'text-xs' : 'text-sm'} opacity-75 mt-0.5 leading-tight`}>
|
| 108 |
{block.subject_name}
|
| 109 |
{block.teacher_name ? ` β ${block.teacher_name}` : ''}
|
| 110 |
</div>
|
|
@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react';
|
|
| 2 |
import { listSectionSchedules, type SectionSchedule } from '../services/sectionScheduleService';
|
| 3 |
import LoadingState from './LoadingState';
|
| 4 |
import ScheduleGrid from './ScheduleGrid';
|
|
|
|
| 5 |
|
| 6 |
export interface ScheduleViewerModalProps {
|
| 7 |
open: boolean;
|
|
@@ -20,6 +21,7 @@ export default function ScheduleViewerModal({
|
|
| 20 |
}: ScheduleViewerModalProps) {
|
| 21 |
const [items, setItems] = useState<SectionSchedule[]>([]);
|
| 22 |
const [loading, setLoading] = useState(false);
|
|
|
|
| 23 |
|
| 24 |
useEffect(() => {
|
| 25 |
if (!open) return;
|
|
@@ -66,11 +68,14 @@ export default function ScheduleViewerModal({
|
|
| 66 |
|
| 67 |
{/* Printable grid area */}
|
| 68 |
<div className="schedule-print-area p-4 overflow-auto flex-1">
|
| 69 |
-
{/* Print-only title */}
|
| 70 |
-
<div className="hidden print:block text-center mb-
|
| 71 |
-
<h1 className="text-
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
| 74 |
</div>
|
| 75 |
|
| 76 |
{loading ? (
|
|
|
|
| 2 |
import { listSectionSchedules, type SectionSchedule } from '../services/sectionScheduleService';
|
| 3 |
import LoadingState from './LoadingState';
|
| 4 |
import ScheduleGrid from './ScheduleGrid';
|
| 5 |
+
import { useAuthStore } from '../store/authStore';
|
| 6 |
|
| 7 |
export interface ScheduleViewerModalProps {
|
| 8 |
open: boolean;
|
|
|
|
| 21 |
}: ScheduleViewerModalProps) {
|
| 22 |
const [items, setItems] = useState<SectionSchedule[]>([]);
|
| 23 |
const [loading, setLoading] = useState(false);
|
| 24 |
+
const organizationName = useAuthStore((s) => s.user?.organization_name || '');
|
| 25 |
|
| 26 |
useEffect(() => {
|
| 27 |
if (!open) return;
|
|
|
|
| 68 |
|
| 69 |
{/* Printable grid area */}
|
| 70 |
<div className="schedule-print-area p-4 overflow-auto flex-1">
|
| 71 |
+
{/* Print-only title: school name primary, section as subtitle */}
|
| 72 |
+
<div className="hidden print:block text-center mb-2">
|
| 73 |
+
{organizationName && <h1 className="text-lg font-bold leading-tight">{organizationName}</h1>}
|
| 74 |
+
<p className="text-sm text-gray-700 leading-tight">
|
| 75 |
+
Horario β {sectionName}
|
| 76 |
+
{academicPeriod ? ` Β· ${academicPeriod}` : ''}
|
| 77 |
+
</p>
|
| 78 |
+
<p className="text-[10px] text-gray-400">Generado: {printDate}</p>
|
| 79 |
</div>
|
| 80 |
|
| 81 |
{loading ? (
|
|
@@ -11,6 +11,7 @@ interface AuthState {
|
|
| 11 |
lastname: string
|
| 12 |
role: string
|
| 13 |
plan: string
|
|
|
|
| 14 |
self_checkin_enabled: boolean
|
| 15 |
checkin_mode: string
|
| 16 |
permissions: string[]
|
|
|
|
| 11 |
lastname: string
|
| 12 |
role: string
|
| 13 |
plan: string
|
| 14 |
+
organization_name?: string
|
| 15 |
self_checkin_enabled: boolean
|
| 16 |
checkin_mode: string
|
| 17 |
permissions: string[]
|
|
@@ -28,7 +28,7 @@
|
|
| 28 |
/* ββ Print / PDF styles βββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 29 |
@page {
|
| 30 |
size: letter landscape;
|
| 31 |
-
margin: 0.
|
| 32 |
}
|
| 33 |
|
| 34 |
@media print {
|
|
|
|
| 28 |
/* ββ Print / PDF styles βββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 29 |
@page {
|
| 30 |
size: letter landscape;
|
| 31 |
+
margin: 0.35in;
|
| 32 |
}
|
| 33 |
|
| 34 |
@media print {
|