diff --git a/management/src/components/StudentAvatar.tsx b/management/src/components/StudentAvatar.tsx index 92e6f91..e89a2a4 100644 --- a/management/src/components/StudentAvatar.tsx +++ b/management/src/components/StudentAvatar.tsx @@ -12,13 +12,25 @@ interface StudentAvatarProps { avatar?: string | null; isOnline?: boolean; size?: number; + showStatusBadge?: boolean; } +export const StudentOnlineBadge: React.FC<{ + isOnline: boolean; + size?: 'sm' | 'md'; +}> = ({ isOnline, size = 'sm' }) => ( + + + {isOnline ? 'Online' : 'Offline'} + +); + export const StudentAvatar: React.FC = ({ fullName, avatar, isOnline = false, size = 48, + showStatusBadge = true, }) => { const [imgFailed, setImgFailed] = useState(false); const avatarUrl = normalizeAvatarUrl(avatar); @@ -30,20 +42,28 @@ export const StudentAvatar: React.FC = ({ }, [avatarUrl]); return ( - - {showImage ? ( - setImgFailed(true)} + + + {showImage ? ( + setImgFailed(true)} + /> + ) : ( + initial + )} + + {showStatusBadge && ( + - ) : ( - initial )} ); diff --git a/management/src/components/StudentDetailModal.tsx b/management/src/components/StudentDetailModal.tsx index 6646171..5f92f96 100644 --- a/management/src/components/StudentDetailModal.tsx +++ b/management/src/components/StudentDetailModal.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import type { StudentItem, StudentSessionLogItem } from '../api'; -import { StudentAvatar } from './StudentAvatar'; +import { StudentAvatar, StudentOnlineBadge } from './StudentAvatar'; import { ProctorStreamPanels } from './ProctorStreamPanels'; interface StudentDetailModalProps { @@ -48,8 +48,8 @@ export const StudentDetailModal: React.FC = ({ Trạng thái - - {isOnline ? '● Online' : '○ Offline'} + + {student.phone && ( diff --git a/management/src/components/WorkspaceSeatingChart.tsx b/management/src/components/WorkspaceSeatingChart.tsx index e3cd364..282a35d 100644 --- a/management/src/components/WorkspaceSeatingChart.tsx +++ b/management/src/components/WorkspaceSeatingChart.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState, useMemo } from 'react'; import type { SeatingTemplate } from './SeatingTemplatesSection'; -import { StudentAvatar } from './StudentAvatar'; +import { StudentAvatar, StudentOnlineBadge } from './StudentAvatar'; interface WorkspaceSeatingChartProps { workspaceId: string; // 'class-' or 'exam-' @@ -330,30 +330,8 @@ export const WorkspaceSeatingChart: React.FC = ({ onDragLeave={handleDragLeave} onDrop={(e) => !isLocked && handleDrop(e, r, c)} onClick={() => isEditingStructure && handleToggleCellLock(r, c)} - className={`seating-grid-cell ${isLocked ? 'locked' : ''} ${isHovered ? 'dragover' : ''}`} - style={{ - minHeight: '80px', - border: isEditingStructure ? '1.5px dashed var(--border-color)' : '1px solid var(--border-color)', - borderRadius: '8px', - display: 'flex', - flexDirection: 'column', - justifyContent: 'center', - alignItems: 'center', - padding: '0.4rem', - position: 'relative', - backgroundColor: isLocked - ? '#e5e7eb' - : isHovered - ? '#dbeafe' - : student - ? '#ffffff' - : '#f9fafb', - color: isLocked ? '#9ca3af' : 'inherit', - cursor: isEditingStructure ? 'pointer' : student ? 'grab' : 'default', - boxShadow: student ? 'var(--shadow-sm)' : 'none', - transition: 'var(--transition)', - borderColor: isHovered ? 'var(--accent)' : isLocked ? '#e5e7eb' : 'var(--border-color)', - }} + className={`seating-grid-cell ${isLocked ? 'locked' : ''} ${isHovered ? 'dragover' : ''} ${student && !isLocked ? (isOnline ? 'occupied-online' : 'occupied-offline') : ''}`} + style={isEditingStructure ? { border: '1.5px dashed var(--border-color)', cursor: 'pointer' } : undefined} draggable={!!student && !isEditingStructure} onDragStart={(e) => student && handleDragStart(e, `cell:${key}`)} > @@ -363,8 +341,8 @@ export const WorkspaceSeatingChart: React.FC = ({ Khóa ) : student ? ( - { if (!isEditingStructure && onStudentClick) { onStudentClick(student.rkId); @@ -373,63 +351,34 @@ export const WorkspaceSeatingChart: React.FC = ({ > {!isEditingStructure && ( { e.stopPropagation(); handleUnseat(key); }} - style={{ - position: 'absolute', - top: '2px', - right: '2px', - border: 'none', - background: '#fee2e2', - color: 'var(--danger)', - width: '18px', - height: '18px', - borderRadius: '50%', - fontSize: '0.65rem', - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - cursor: 'pointer', - fontWeight: 700, - }} title="Cho học viên rời chỗ" > × )} - - + + {student.fullName.split(' ').pop()} - + {student.studentCode} + {!isEditingStructure && } {student.paperTitle && ( - + 📄 {student.paperTitle} )} ) : ( - - + + H{r + 1}-C{c + 1} - Trống + Trống )} @@ -458,18 +407,9 @@ export const WorkspaceSeatingChart: React.FC = ({ {/* Grid Container */} {gridItems} @@ -709,8 +649,8 @@ export const WorkspaceSeatingChart: React.FC = ({ {seatLabel} - - {isOnline ? 'Online' : 'Offline'} + + = ({ draggable onDragStart={(e) => handleDragStart(e, `unseated:${s.rkId}`)} onClick={() => onStudentClick && onStudentClick(s.rkId)} - style={{ - display: 'flex', - alignItems: 'center', - gap: '0.5rem', - padding: '0.5rem', - border: '1px solid var(--border-color)', - borderRadius: '8px', - backgroundColor: '#ffffff', - cursor: onStudentClick ? 'pointer' : 'grab', - transition: 'var(--transition)', - userSelect: 'none', - boxShadow: 'var(--shadow-sm)', - }} - className="student-drag-item" + className={`seating-unseated-card ${isOnline ? 'online' : 'offline'} ${onStudentClick ? 'seating-unseated-card--clickable' : ''} student-drag-item`} > - - + + {s.fullName} {s.studentCode} {s.paperTitle && ` · 📄 ${s.paperTitle}`} + - ); }) diff --git a/management/src/index.css b/management/src/index.css index 61966c0..17b2c71 100644 --- a/management/src/index.css +++ b/management/src/index.css @@ -2468,17 +2468,283 @@ input:checked + .slider:before { border-color: var(--border-color); } +.student-workspace-avatar.offline.has-image { + border-color: #cbd5e1; + filter: grayscale(0.15); +} + +.student-workspace-avatar.offline:not(.has-image) { + background: #f1f5f9; + color: #94a3b8; + border-color: #e2e8f0; +} + +.student-workspace-avatar.online.has-image, .student-status-card.online .student-workspace-avatar.has-image { border-color: var(--success); box-shadow: 0 0 0 2px rgba(13, 159, 110, 0.2); } +.student-workspace-avatar.online:not(.has-image), .student-status-card.online .student-workspace-avatar:not(.has-image) { background: var(--accent); color: white; border-color: var(--accent); } +.student-avatar-wrap { + position: relative; + flex-shrink: 0; + display: inline-flex; +} + +.student-avatar-status-ring { + position: absolute; + bottom: -1px; + right: -1px; + width: 11px; + height: 11px; + border-radius: 50%; + border: 2px solid #fff; + box-shadow: 0 1px 4px rgba(15, 23, 42, 0.18); + z-index: 2; +} + +.student-avatar-status-ring.online { + background: var(--success); + animation: pulse-online 1.8s infinite ease-in-out; +} + +.student-avatar-status-ring.offline { + background: #94a3b8; +} + +.student-online-badge { + display: inline-flex; + align-items: center; + gap: 0.35rem; + border-radius: 999px; + font-weight: 700; + letter-spacing: 0.03em; + text-transform: uppercase; + white-space: nowrap; + line-height: 1; +} + +.student-online-badge--sm { + padding: 0.24rem 0.5rem; + font-size: 0.6rem; +} + +.student-online-badge--md { + padding: 0.28rem 0.6rem; + font-size: 0.68rem; +} + +.student-online-badge.online { + background: rgba(13, 159, 110, 0.12); + color: #0d9f6e; + border: 1px solid rgba(13, 159, 110, 0.22); +} + +.student-online-badge.offline { + background: #f1f5f9; + color: #64748b; + border: 1px solid #e2e8f0; +} + +.student-online-badge-dot { + width: 6px; + height: 6px; + border-radius: 50%; + flex-shrink: 0; +} + +.student-online-badge.online .student-online-badge-dot { + background: var(--success); + box-shadow: 0 0 0 2px rgba(13, 159, 110, 0.2); +} + +.student-online-badge.offline .student-online-badge-dot { + background: #94a3b8; +} + +.seating-grid-cell.occupied-online { + border-color: rgba(13, 159, 110, 0.38) !important; + background: linear-gradient(180deg, #ecfdf5 0%, #ffffff 55%) !important; + box-shadow: 0 2px 8px rgba(13, 159, 110, 0.1) !important; +} + +.seating-grid-cell.occupied-offline { + border-color: #e2e8f0 !important; + background: linear-gradient(180deg, #f8fafc 0%, #ffffff 55%) !important; + box-shadow: var(--shadow-sm) !important; +} + +.seating-grid-board { + --seating-cell-min-width: 136px; + --seating-cell-min-height: 156px; + display: grid; + gap: 10px; + flex: 1; + padding: 10px; + background-color: var(--bg-app); + border-radius: var(--radius-md); + border: 1px solid var(--border-color); + align-content: start; + overflow: auto; + min-height: 0; +} + +.seating-grid-cell { + min-height: var(--seating-cell-min-height); + border: 1px solid var(--border-color); + border-radius: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + padding: 0.55rem 0.45rem 0.5rem; + position: relative; + transition: var(--transition); +} + +.seating-grid-cell.locked { + background: #e5e7eb; + color: #9ca3af; +} + +.seating-grid-cell.dragover { + background: #dbeafe !important; + border-color: var(--accent) !important; +} + +.seating-grid-cell:not(.locked):not(.occupied-online):not(.occupied-offline):not(.dragover) { + background: #f9fafb; +} + +.seating-grid-cell:not(.locked) { + cursor: default; +} + +.seating-grid-cell.occupied-online, +.seating-grid-cell.occupied-offline { + cursor: grab; +} + +.seating-seat-card { + display: flex; + flex-direction: column; + align-items: center; + text-align: center; + width: 100%; + gap: 0.28rem; +} + +.seating-seat-card--clickable { + cursor: pointer; +} + +.seating-seat-name { + font-size: 0.8rem; + font-weight: 700; + margin-top: 2px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + width: 100%; + padding: 0 2px; + line-height: 1.2; +} + +.seating-seat-code { + font-size: 0.68rem; + color: var(--text-secondary); + font-family: monospace; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + width: 100%; + line-height: 1.2; +} + +.seating-seat-paper { + font-size: 0.64rem; + background: var(--accent-light); + color: var(--accent); + padding: 2px 6px; + border-radius: 4px; + margin-top: 1px; + font-weight: 600; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + max-width: 100%; + line-height: 1.25; +} + +.seating-seat-empty-label { + font-size: 0.75rem; + color: var(--text-muted); + font-weight: 600; +} + +.seating-seat-empty-seat { + font-size: 0.68rem; + color: var(--text-muted); +} + +.seating-seat-unseat-btn { + position: absolute; + top: 4px; + right: 4px; + border: none; + background: #fee2e2; + color: var(--danger); + width: 20px; + height: 20px; + border-radius: 50%; + font-size: 0.7rem; + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + font-weight: 700; +} + +.seating-unseated-card { + display: flex; + align-items: center; + gap: 0.5rem; + padding: 0.55rem 0.6rem; + border: 1px solid var(--border-color); + border-radius: 10px; + background: #fff; + cursor: grab; + transition: var(--transition); + user-select: none; + box-shadow: var(--shadow-sm); +} + +.seating-unseated-card.online { + border-color: rgba(13, 159, 110, 0.28); + background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 70%); +} + +.seating-unseated-card.offline { + border-color: #e2e8f0; + background: #f8fafc; +} + +.seating-unseated-card:hover { + border-color: var(--accent); + box-shadow: var(--shadow-md); +} + +.seating-unseated-card--clickable { + cursor: pointer; +} + .app-suggestion-badge { font-size: 0.72rem; padding: 0.2rem 0.5rem;