This commit is contained in:
@@ -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-<id>' or 'exam-<id>'
|
||||
@@ -330,30 +330,8 @@ export const WorkspaceSeatingChart: React.FC<WorkspaceSeatingChartProps> = ({
|
||||
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<WorkspaceSeatingChartProps> = ({
|
||||
<span style={{ fontSize: '0.72rem', color: '#9ca3af', fontWeight: 600 }}>Khóa</span>
|
||||
</div>
|
||||
) : student ? (
|
||||
<div
|
||||
style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', textAlign: 'center', width: '100%', cursor: (!isEditingStructure && onStudentClick) ? 'pointer' : 'inherit' }}
|
||||
<div
|
||||
className={`seating-seat-card ${!isEditingStructure && onStudentClick ? 'seating-seat-card--clickable' : ''}`}
|
||||
onClick={() => {
|
||||
if (!isEditingStructure && onStudentClick) {
|
||||
onStudentClick(student.rkId);
|
||||
@@ -373,63 +351,34 @@ export const WorkspaceSeatingChart: React.FC<WorkspaceSeatingChartProps> = ({
|
||||
>
|
||||
{!isEditingStructure && (
|
||||
<button
|
||||
type="button"
|
||||
className="seating-seat-unseat-btn"
|
||||
onClick={(e) => { 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ỗ"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
)}
|
||||
<StudentAvatar fullName={student.fullName} avatar={student.avatar} isOnline={isOnline} size={32} />
|
||||
<span style={{ fontSize: '0.75rem', fontWeight: 700, marginTop: '4px', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', width: '100%', padding: '0 2px' }}>
|
||||
<StudentAvatar fullName={student.fullName} avatar={student.avatar} isOnline={isOnline} size={40} />
|
||||
<span className="seating-seat-name">
|
||||
{student.fullName.split(' ').pop()}
|
||||
</span>
|
||||
<span style={{ fontSize: '0.65rem', color: 'var(--text-secondary)', fontFamily: 'monospace' }}>
|
||||
<span className="seating-seat-code">
|
||||
{student.studentCode}
|
||||
</span>
|
||||
{!isEditingStructure && <StudentOnlineBadge isOnline={isOnline} size="sm" />}
|
||||
{student.paperTitle && (
|
||||
<span
|
||||
style={{
|
||||
fontSize: '0.62rem',
|
||||
background: 'var(--accent-light)',
|
||||
color: 'var(--accent)',
|
||||
padding: '1px 4px',
|
||||
borderRadius: '4px',
|
||||
marginTop: '2px',
|
||||
fontWeight: 600,
|
||||
whiteSpace: 'nowrap',
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
maxWidth: '100%'
|
||||
}}
|
||||
title={`Đề: ${student.paperTitle}`}
|
||||
>
|
||||
<span className="seating-seat-paper" title={`Đề: ${student.paperTitle}`}>
|
||||
📄 {student.paperTitle}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', opacity: 0.4 }}>
|
||||
<span style={{ fontSize: '0.72rem', color: 'var(--text-muted)', fontWeight: 600 }}>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', opacity: 0.4, gap: '0.15rem' }}>
|
||||
<span className="seating-seat-empty-label">
|
||||
H{r + 1}-C{c + 1}
|
||||
</span>
|
||||
<span style={{ fontSize: '0.65rem', color: 'var(--text-muted)' }}>Trống</span>
|
||||
<span className="seating-seat-empty-seat">Trống</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -458,18 +407,9 @@ export const WorkspaceSeatingChart: React.FC<WorkspaceSeatingChartProps> = ({
|
||||
|
||||
{/* Grid Container */}
|
||||
<div
|
||||
className="seating-grid-board"
|
||||
style={{
|
||||
display: 'grid',
|
||||
gridTemplateColumns: `repeat(${layout.cols}, minmax(75px, 1fr))`,
|
||||
gap: '8px',
|
||||
flex: 1,
|
||||
padding: '8px',
|
||||
backgroundColor: 'var(--bg-app)',
|
||||
borderRadius: 'var(--radius-md)',
|
||||
border: '1px solid var(--border-color)',
|
||||
alignContent: 'start',
|
||||
overflow: 'auto',
|
||||
minHeight: 0,
|
||||
gridTemplateColumns: `repeat(${layout.cols}, minmax(var(--seating-cell-min-width), 1fr))`,
|
||||
}}
|
||||
>
|
||||
{gridItems}
|
||||
@@ -709,8 +649,8 @@ export const WorkspaceSeatingChart: React.FC<WorkspaceSeatingChartProps> = ({
|
||||
{seatLabel}
|
||||
</span>
|
||||
</td>
|
||||
<td style={{ color: isOnline ? 'var(--success)' : 'var(--text-muted)', fontWeight: 700 }}>
|
||||
{isOnline ? 'Online' : 'Offline'}
|
||||
<td>
|
||||
<StudentOnlineBadge isOnline={isOnline} size="md" />
|
||||
</td>
|
||||
<td style={{ textAlign: 'right' }}>
|
||||
<button
|
||||
@@ -780,31 +720,18 @@ export const WorkspaceSeatingChart: React.FC<WorkspaceSeatingChartProps> = ({
|
||||
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`}
|
||||
>
|
||||
<StudentAvatar fullName={s.fullName} avatar={s.avatar} isOnline={isOnline} size={28} />
|
||||
<div style={{ display: 'flex', flexDirection: 'column', overflow: 'hidden', flex: 1 }}>
|
||||
<StudentAvatar fullName={s.fullName} avatar={s.avatar} isOnline={isOnline} size={32} />
|
||||
<div style={{ display: 'flex', flexDirection: 'column', overflow: 'hidden', flex: 1, minWidth: 0, gap: '0.2rem' }}>
|
||||
<span style={{ fontSize: '0.8rem', fontWeight: 600, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>
|
||||
{s.fullName}
|
||||
</span>
|
||||
<span style={{ fontSize: '0.7rem', color: 'var(--text-secondary)', fontFamily: 'monospace', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>
|
||||
{s.studentCode} {s.paperTitle && ` · 📄 ${s.paperTitle}`}
|
||||
</span>
|
||||
<StudentOnlineBadge isOnline={isOnline} size="sm" />
|
||||
</div>
|
||||
<span className={isOnline ? 'pulse-dot-online' : 'status-badge-offline'} style={{ width: '6px', height: '6px' }} />
|
||||
</div>
|
||||
);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user