From 2a5d7efcbb1bd1a13d110c4daa5828c13ad41ce8 Mon Sep 17 00:00:00 2001 From: primakov Date: Sun, 23 Mar 2025 12:09:56 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BD=D0=BE=D0=B2=D1=8B=D0=B5=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=B2=D0=BE=D0=B4=D1=8B=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D0=BD=D0=BE=D1=8D=D0=BA=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=80=D0=B5=D0=B6=D0=B8=D0=BC=D0=B0?= =?UTF-8?q?=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D1=8B=20=D0=BF=D0=BE?= =?UTF-8?q?=D1=81=D0=B5=D1=89=D0=B0=D0=B5=D0=BC=D0=BE=D1=81=D1=82=D0=B8=20?= =?UTF-8?q?=D0=B2=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BB=D0=BE=D0=BA?= =?UTF-8?q?=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8=20(en.json=20?= =?UTF-8?q?=D0=B8=20ru.json).=20=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=20AttendanceTable:=20=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE?= =?UTF-8?q?=D0=B6=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D0=BE=D1=82=D0=BE=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=82=D0=B0=D0=B1?= =?UTF-8?q?=D0=BB=D0=B8=D1=86=D1=8B=20=D0=B2=20=D0=BF=D0=BE=D0=BB=D0=BD?= =?UTF-8?q?=D0=BE=D1=8D=D0=BA=D1=80=D0=B0=D0=BD=D0=BD=D0=BE=D0=BC=20=D1=80?= =?UTF-8?q?=D0=B5=D0=B6=D0=B8=D0=BC=D0=B5=20=D1=81=20=D1=81=D0=BE=D0=BE?= =?UTF-8?q?=D1=82=D0=B2=D0=B5=D1=82=D1=81=D1=82=D0=B2=D1=83=D1=8E=D1=89?= =?UTF-8?q?=D0=B8=D0=BC=D0=B8=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B0=D0=BC?= =?UTF-8?q?=D0=B8=20=D0=B8=20=D0=BC=D0=BE=D0=B4=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D1=8B=D0=BC=20=D0=BE=D0=BA=D0=BD=D0=BE=D0=BC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/en.json | 3 + locales/ru.json | 3 + .../attendance/components/AttendanceTable.tsx | 197 +++++++++++------- 3 files changed, 126 insertions(+), 77 deletions(-) diff --git a/locales/en.json b/locales/en.json index e0ffdc3..b5cb81d 100644 --- a/locales/en.json +++ b/locales/en.json @@ -100,6 +100,9 @@ "journal.pl.attendance.table.copy": "Copy Table", "journal.pl.attendance.table.show": "Show Table", "journal.pl.attendance.table.hide": "Hide Table", + "journal.pl.attendance.table.fullscreen": "Fullscreen", + "journal.pl.attendance.table.exitFullscreen": "Exit Fullscreen", + "journal.pl.attendance.table.attendanceData": "Attendance Data", "journal.pl.attendance.table.copySuccess": "Table copied", "journal.pl.attendance.table.copySuccessDescription": "Table data successfully copied to clipboard", "journal.pl.attendance.table.copyError": "Copy error", diff --git a/locales/ru.json b/locales/ru.json index 99a0662..70548c8 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -95,6 +95,9 @@ "journal.pl.attendance.table.copy": "Копировать таблицу", "journal.pl.attendance.table.show": "Показать таблицу", "journal.pl.attendance.table.hide": "Скрыть таблицу", + "journal.pl.attendance.table.fullscreen": "На весь экран", + "journal.pl.attendance.table.exitFullscreen": "Выйти из полноэкранного режима", + "journal.pl.attendance.table.attendanceData": "Данные о посещаемости", "journal.pl.attendance.table.copySuccess": "Таблица скопирована", "journal.pl.attendance.table.copySuccessDescription": "Данные таблицы успешно скопированы в буфер обмена", "journal.pl.attendance.table.copyError": "Ошибка копирования", diff --git a/src/pages/attendance/components/AttendanceTable.tsx b/src/pages/attendance/components/AttendanceTable.tsx index 3653933..a3206d0 100644 --- a/src/pages/attendance/components/AttendanceTable.tsx +++ b/src/pages/attendance/components/AttendanceTable.tsx @@ -17,10 +17,17 @@ import { Icon, Tooltip, Avatar, - AvatarBadge + AvatarBadge, + Modal, + ModalOverlay, + ModalContent, + ModalHeader, + ModalBody, + ModalCloseButton, + useDisclosure } from '@chakra-ui/react' import { CopyIcon, ChevronDownIcon, ChevronUpIcon } from '@chakra-ui/icons' -import { FaSmile, FaMeh, FaFrown, FaSadTear } from 'react-icons/fa' +import { FaSmile, FaMeh, FaFrown, FaSadTear, FaExpand, FaCompress } from 'react-icons/fa' import dayjs from 'dayjs' import { useTranslation } from 'react-i18next' import { getGravatarURL } from '../../../utils/gravatar' @@ -36,6 +43,7 @@ export const AttendanceTable: React.FC = ({ data }) => { const toast = useToast() const { t } = useTranslation() const [showTable, setShowTable] = useState(false) + const { isOpen, onOpen, onClose } = useDisclosure() const getPresentColor = () => { return colorMode === 'dark' ? 'green.600' : 'green.100' @@ -178,6 +186,76 @@ export const AttendanceTable: React.FC = ({ data }) => { return {t('journal.pl.common.noData')} } + // Создаем компонент таблицы для переиспользования + const AttendanceTableContent = () => ( + + + + {data.teachers?.map(teacher => ( + + ))} + + + {data.students.map((student) => ( + + ))} + + + + {data.attendance.map((lesson) => ( + + {data.teachers?.map((teacher) => { + const wasThere = Boolean(lesson.teachers) && + lesson.teachers.findIndex((u) => u.sub === teacher.sub) !== -1 + return ( + + ) + })} + + + + {data.students.map((st) => { + const wasThere = + lesson.students.findIndex((u) => u.sub === st.sub) !== -1 + return ( + + ) + })} + + ))} + +
{teacher.value}{t('journal.pl.common.date')}{t('journal.pl.common.lessonName')} + + + {student.name || student.value || t('journal.pl.common.name')} + +
+ {wasThere ? ( + + ) : ( + + )} + {dayjs(lesson.date).format('DD.MM.YYYY')} + {wasThere ? ( + + ) : ( + + )} +
+ ) + return ( = ({ data }) => { bg={colorMode === 'dark' ? 'gray.700' : 'white'} > - + + + + +