import React from 'react' import { Box } from '@chakra-ui/react' import { motion } from 'framer-motion' import { User, Reaction } from '../../__data__/model' import { UserCard } from '../user-card' import { StudentCardBack } from './StudentCardBack' import { useColorMode } from '@chakra-ui/react' // Компонент маленькой батарейки для отображения в углу карточки const BatteryIndicator: React.FC<{ student: User & { present?: boolean; recentlyPresent?: boolean } }> = ({ student }) => { const { colorMode } = useColorMode(); // Та же логика из StudentCardBack для определения уровня батареи const getAttendanceLevel = () => { if (student.present) { return student.recentlyPresent ? 4 : 5; } const id = student.sub || ''; const idSum = id.split('').reduce((sum, char) => sum + char.charCodeAt(0), 0); return Math.min(3, Math.floor((idSum % 100) / 25)); } const batteryLevel = getAttendanceLevel(); // Цвета для разных уровней заряда батареи const colors = [ // Empty (0) { primary: colorMode === "light" ? "#E53E3E" : "#F56565" }, // Very Low (1) { primary: colorMode === "light" ? "#DD6B20" : "#ED8936" }, // Low (2) { primary: colorMode === "light" ? "#D69E2E" : "#ECC94B" }, // Medium (3) { primary: colorMode === "light" ? "#38B2AC" : "#4FD1C5" }, // Good (4) { primary: colorMode === "light" ? "#3182CE" : "#4299E1" }, // Excellent (5) { primary: colorMode === "light" ? "#38A169" : "#48BB78" } ]; const color = colors[batteryLevel].primary; // Функция для определения заполненности сегментов const getSegmentFill = (segmentIndex: number) => { return segmentIndex <= batteryLevel ? color : 'transparent'; } return ( {/* Battery outline */} {/* Battery cap */} {/* Battery segments */} {/* Lightning icon if recently joined or fully charged */} {(student.recentlyPresent || batteryLevel === 5) && ( )} ); }; interface StudentCardProps { student: User & { present?: boolean; recentlyPresent?: boolean } onAddUser: (user: User) => void reaction?: Reaction } export const StudentCard: React.FC = ({ student, onAddUser, reaction }) => { return ( {/* Container for 3D effect */} {/* Front side - visible when present */} {/* Battery indicator in corner */} {/* Back side */} ) }