diff --git a/client/src/App.jsx b/client/src/App.jsx index 8d8ef24b..af065695 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -223,7 +223,7 @@ const App = () => ( options={{ menuGroup: 'report' }} icon={RuleIcon} /> - {isSeminarAttendanceYemot(permissions) && ( + {(isSeminarAttendanceYemot(permissions) || isAdmin(permissions)) && ( (value ? new Date(value).toLocaleTimeString('he-IL const NO_KLASS_KEY = 'none'; -// The view has one row per lesson taught; each lesson gets its own card, -// so a teacher who taught two lessons shows as two cards. -function groupByTeacherAndDate(rows) { - const groups = new Map(); +// A lesson with this many missing girls or more is highlighted in red; fewer (but some) in orange. +const HIGH_MISSING_THRESHOLD = 5; + +const missingCount = (row) => Number(row.missingGirlsCount) || 0; + +const missingPillSx = (count) => ({ + display: 'inline-block', + minWidth: 32, + textAlign: 'center', + px: 1, + borderRadius: 999, + fontSize: 14, + fontVariantNumeric: 'tabular-nums', + ...(count === 0 + ? { color: 'text.secondary' } + : count >= HIGH_MISSING_THRESHOLD + ? { bgcolor: '#fde7e6', color: '#a5221a', fontWeight: 'bold' } + : { bgcolor: '#fff1dc', color: '#9a4a00', fontWeight: 500 }), +}); + +// The view has one row per lesson taught (already sorted by reportHour); group them into one card per class. +function groupByKlass(rows) { + const klasses = new Map(); rows.forEach((row) => { - const key = row.id; - if (!groups.has(key)) { - groups.set(key, { ...row, lessonRows: [] }); + // Lessons without a class are grouped per user, so an admin never sees two users' rows in one card. + const key = row.klassReferenceId ?? `${NO_KLASS_KEY}_${row.userId}`; + if (!klasses.has(key)) { + klasses.set(key, { key, klassReferenceId: row.klassReferenceId, userId: row.userId, lessons: [] }); } - if (row.lessonReferenceId) { - groups.get(key).lessonRows.push(row); - } - }); - return [...groups.values()]; -} - -// Split teacher cards into one column per class, so reports are easy to scan by class. -function groupByKlass(groups) { - const columns = new Map(); - groups.forEach((group) => { - const key = group.klassReferenceId ?? NO_KLASS_KEY; - if (!columns.has(key)) { - columns.set(key, { klassReferenceId: group.klassReferenceId, groups: [] }); - } - columns.get(key).groups.push(group); + klasses.get(key).lessons.push(row); }); - return [...columns.values()].sort((a, b) => { + return [...klasses.values()].sort((a, b) => { if (!a.klassReferenceId) return 1; if (!b.klassReferenceId) return -1; return a.klassReferenceId - b.klassReferenceId; }); } -// Total missing girls for the whole card: sum across its lessons, or the card's own -// count when it has no per-lesson breakdown (the "ללא שיוך שיעור" case). -function getTotalMissingGirls(group) { - return group.lessonRows.length > 0 - ? group.lessonRows.reduce((sum, row) => sum + (Number(row.missingGirlsCount) || 0), 0) - : Number(group.missingGirlsCount) || 0; -} +const sumMissing = (rows) => rows.reduce((sum, row) => sum + missingCount(row), 0); + +const SummaryTiles = ({ rows, klassCount }) => { + const tiles = [ + { label: 'שיעורים שדווחו', value: rows.length }, + { label: 'כיתות', value: klassCount }, + { label: 'מורות', value: new Set(rows.map((row) => row.teacherReferenceId)).size }, + { label: 'סה״כ חסרות', value: sumMissing(rows) }, + ]; + return ( + + {tiles.map((tile) => ( + + {tile.label} + {tile.value} + + ))} + + ); +}; + +const LessonRow = ({ row, showDate }) => { + const count = missingCount(row); + return ( + + + + {showDate && `${formatDate(row.reportDate)} `}{formatHour(row.reportHour)} + + + {row.lessonReferenceId ? ( + + + + ) : 'ללא שיוך שיעור'} + + + + + + + + {count === 0 ? '–' : count} + + + + ); +}; const TeacherReportCards = ({ isAdmin }) => { - const { data } = useListContext(); - const groups = groupByTeacherAndDate(data || []); - const columns = groupByKlass(groups); + const { data, total, filterValues } = useListContext(); + const rows = data || []; + const klasses = groupByKlass(rows); + // Show the date on each row unless the filter is a single day. + const showDate = !filterValues?.['reportDate:$gte'] || filterValues['reportDate:$gte'] !== filterValues['reportDate:$lte']; return ( - - {columns.map((column) => ( - - - {column.klassReferenceId ? ( - - - - - - ) : 'ללא כיתה'} - - - {column.groups.map((group) => { - const totalMissingGirls = getTotalMissingGirls(group); - return ( - - - - - - - - - - {totalMissingGirls > 0 && ( - - חסרו {totalMissingGirls} - - )} - - - {isAdmin && } - {formatDate(group.reportDate)} - {formatHour(group.reportHour)} - - - {group.lessonRows.length > 0 ? ( - group.lessonRows.map((row) => ( - - - - - - - - )) - ) : ( - ללא שיוך שיעור - )} - - - + + {total > rows.length && ( + + מוצגים {rows.length} מתוך {total} שיעורים. צמצמו את טווח התאריכים כדי לראות את כולם. + + )} + + + {klasses.map((klass) => { + const lessonCount = klass.lessons.length; + return ( + + + + {klass.klassReferenceId ? ( + + + + + + ) : 'ללא כיתה'} + + + {lessonCount === 1 ? 'שיעור אחד' : `${lessonCount} שיעורים`} · חסרו {sumMissing(klass.lessons)} + + + {isAdmin && ( + + + + - ); - })} - - - ))} + )} + {klass.lessons.map((row) => ( + + ))} + + ); + })} + ); }; diff --git a/client/src/roadmapFeatures.js b/client/src/roadmapFeatures.js index aed7a00d..251a8a8e 100644 --- a/client/src/roadmapFeatures.js +++ b/client/src/roadmapFeatures.js @@ -30,6 +30,7 @@ export default [ { html: 'הוספת דף "צור קשר" לשליחת פנייה עם קבצים מצורפים', status: 'בוצע', statusColor: 'success' }, { html: 'תשתית משימות רקע: ייצוא נתונים אסינכרוני, תזמונים קבועים וניטור משימות', status: 'בוצע', statusColor: 'success' }, { html: 'ניקוי אוטומטי של נוכחות שיעור נבחר, לפי כיתה/מסלול לשמירה, בכל מוצאי שבת', status: 'בוצע', statusColor: 'success' }, + { html: 'עיצוב חדש לדוח המורות שדיווחו: כרטיס לכל כיתה עם שורה לכל שיעור, צביעת מספר החסרות וריבועי סיכום', status: 'בוצע', statusColor: 'success' }, // { html: 'הגדרת תקופת זמן לפי תאריכים', status: 'בקרוב', statusColor: 'warning' }, // { html: 'הגדרת תקופת זמן לפי יום בשבוע', status: 'בוצע', statusColor: 'success' },