import React, { useState, useRef } from 'react' import { Project } from '@/types' import { ImageTable } from './ImageTable' interface DataTabProps { project: Project onUploadImages: (fileNames: string[], files?: File[]) => void hideSampleUpload?: boolean } interface DatasetBatch { id: string batchName: string uploadedBy: string uploadedAt: string imageCount: number status: 'Đã phân công' | 'Đang gán nhãn' | 'Hoàn thành' } export const DataTab: React.FC = ({ project, onUploadImages, hideSampleUpload = false, }) => { const imageCount = project.stats.totalImages const fileInputRef = useRef(null) const [isDragging, setIsDragging] = useState(false) const [batches, setBatches] = useState([ { id: 'batch-03', batchName: 'batch_2026_10_morning_cam04', uploadedBy: 'Minh Anh', uploadedAt: 'Hôm nay, 08:30', imageCount: 320, status: 'Đang gán nhãn', }, { id: 'batch-02', batchName: 'batch_2026_10_intersection_02', uploadedBy: 'Minh Anh', uploadedAt: 'Hôm qua, 16:15', imageCount: 480, status: 'Đang gán nhãn', }, { id: 'batch-01', batchName: 'batch_2026_09_initial_seed', uploadedBy: 'Thu Hà', uploadedAt: '5 ngày trước', imageCount: 480, status: 'Hoàn thành', }, ]) const handleFilesSelected = (files: FileList | null) => { if (!files || files.length === 0) return const list = Array.from(files) onUploadImages( list.map((f) => f.name), list ) setBatches((prev) => [ { id: `batch-${Date.now()}`, batchName: `upload_batch_${new Date().toISOString().slice(0, 10).replace(/-/g, '_')}`, uploadedBy: 'Minh Anh', uploadedAt: 'Vừa tải lên', imageCount: list.length, status: 'Đã phân công', }, ...prev, ]) } const handleSimulatedSampleUpload = () => { const sampleNames = [ `traffic_${String(327 + imageCount).padStart(5, '0')}.jpg`, `traffic_${String(328 + imageCount).padStart(5, '0')}.jpg`, `traffic_${String(329 + imageCount).padStart(5, '0')}.jpg`, ] onUploadImages(sampleNames) setBatches((prev) => [ { id: `batch-${Date.now()}`, batchName: `camera_import_${batches.length + 1}`, uploadedBy: 'Minh Anh', uploadedAt: 'Vừa tải lên', imageCount: sampleNames.length, status: 'Đã phân công', }, ...prev, ]) } return (
{/* Upload Dropzone */}
{ e.preventDefault() setIsDragging(true) }} onDragLeave={() => setIsDragging(false)} onDrop={(e) => { e.preventDefault() setIsDragging(false) handleFilesSelected(e.dataTransfer.files) }} className={`flex flex-col items-center justify-center rounded-2xl border-2 border-dashed p-8 text-center transition ${ isDragging ? 'border-[#C95C3C] bg-[#FDF4F1]' : 'border-slate-300 bg-white hover:border-slate-400' }`} > handleFilesSelected(e.target.files)} />

Kéo thả ảnh hoặc thư mục dữ liệu vào đây

Hỗ trợ định dạng JPG, PNG, WEBP tối đa 25MB/ảnh cho dự án{' '} {project.slug}

{!hideSampleUpload && ( )}
{/* Dataset Batches Table */}

Lô dữ liệu đã tải lên

Quản lý các đợt nhập ảnh vào dự án và trạng thái phân công

{batches.length} lô dữ liệu
{batches.map((batch) => (

{batch.batchName}

Tải lên bởi {batch.uploadedBy} · {batch.uploadedAt}

{batch.imageCount.toLocaleString('vi-VN')} ảnh {batch.status}
))}
{/* Full Image Table (self-paginated) */} m.name)} />
) }