Обновлены компоненты для учета только прошедших лекций в статистике посещаемости. Добавлено мобильное отображение в компонентах LessonItems и Item, улучшена логика фильтрации лекций. Реализовано отображение QR-кода с учетом темы оформления.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useMemo } from 'react'
|
||||
import dayjs from 'dayjs'
|
||||
import { AttendanceData } from './useAttendanceData'
|
||||
|
||||
export interface AttendanceStats {
|
||||
@@ -27,13 +28,17 @@ export const useAttendanceStats = (data: AttendanceData): AttendanceStats => {
|
||||
}
|
||||
}
|
||||
|
||||
const totalLessons = data.attendance.length
|
||||
const now = dayjs()
|
||||
// Фильтруем лекции, оставляя только те, которые уже прошли (исключаем будущие)
|
||||
const pastLessons = data.attendance.filter(lesson => dayjs(lesson.date).isBefore(now))
|
||||
|
||||
const totalLessons = pastLessons.length
|
||||
|
||||
// Рассчитываем посещаемость для каждого студента
|
||||
const studentAttendance = data.students.map(student => {
|
||||
let attended = 0
|
||||
|
||||
data.attendance.forEach(lesson => {
|
||||
pastLessons.forEach(lesson => {
|
||||
if (lesson.students.some(s => s.sub === student.sub)) {
|
||||
attended++
|
||||
}
|
||||
@@ -48,7 +53,7 @@ export const useAttendanceStats = (data: AttendanceData): AttendanceStats => {
|
||||
})
|
||||
|
||||
// Рассчитываем статистику посещаемости для каждого урока
|
||||
const lessonsAttendance = data.attendance.map(lesson => {
|
||||
const lessonsAttendance = pastLessons.map(lesson => {
|
||||
const attendedStudents = lesson.students.length
|
||||
const attendancePercent = data.students.length > 0
|
||||
? (attendedStudents / data.students.length) * 100
|
||||
|
||||
Reference in New Issue
Block a user