feat: scaffold complete danable frontend architecture with all pages, layouts, stores, and 3 annotator modes

This commit is contained in:
quanganh2k4 2026-10-30 00:33:07 +07:00
commit 78848dd7d1
173 changed files with 18649 additions and 0 deletions

View file

@ -0,0 +1,100 @@
import React from 'react'
import clsx from 'clsx'
import { useAnnotatorStore } from '../../annotatorStore'
import { StatusBadge } from './StatusBadge'
import { ImageFlagCheckboxes } from './ImageFlagCheckboxes'
import { ReviewActions } from './ReviewActions'
export const ClassificationPanel: React.FC = () => {
const classes = useAnnotatorStore((s) => s.project.classes)
const currentImage = useAnnotatorStore((s) => s.images[s.currentImageIndex])
const classificationByImageId = useAnnotatorStore((s) => s.classificationByImageId)
const statusByImageId = useAnnotatorStore((s) => s.statusByImageId)
const setClassificationLabel = useAnnotatorStore((s) => s.setClassificationLabel)
if (!currentImage) return null
const activeClassId = classificationByImageId[currentImage.id] ?? 'cls-car'
const activeClass = classes.find((c) => c.id === activeClassId) ?? classes[0]
const currentStatus = statusByImageId[currentImage.id] ?? 'pending_review'
return (
<div className="flex flex-col space-y-3.5 rounded-2xl border border-slate-200/80 bg-white p-5 shadow-2xs">
{/* Header */}
<div className="flex items-center justify-between">
<h3 className="text-sm font-bold text-slate-900">Nhãn cấp ảnh</h3>
<span className="text-xs font-medium text-[#4F46E5]">1 nhãn / ảnh</span>
</div>
{/* Status Badge */}
<div>
<StatusBadge status={currentStatus} />
</div>
<p className="text-xs text-slate-500">Chọn một lớp cho toàn bộ ảnh.</p>
{/* Class Radio Cards */}
<div className="space-y-2.5">
{classes.map((cls, index) => {
const isSelected = cls.id === activeClassId
return (
<button
key={cls.id}
type="button"
onClick={() => setClassificationLabel(cls.id)}
className={clsx(
'flex w-full items-center justify-between rounded-xl border px-3.5 py-3 text-left transition-all',
isSelected
? 'border-[#4F46E5] bg-[#FDECE7] shadow-2xs'
: 'border-slate-200 bg-white hover:border-slate-300'
)}
>
<div className="flex items-center gap-2.5">
<span
className={clsx(
'flex h-4 w-4 items-center justify-center rounded-full border transition-colors',
isSelected
? 'border-[#4F46E5] bg-[#4F46E5]'
: 'border-slate-300 bg-white'
)}
>
{isSelected && (
<span className="h-1.5 w-1.5 rounded-full bg-white" />
)}
</span>
<span className="text-xs font-semibold text-slate-900">
{cls.name}
</span>
</div>
<span className="font-mono text-xs text-slate-400">
{cls.shortcutKey ?? index + 1}
</span>
</button>
)
})}
</div>
{/* Image Flags */}
<ImageFlagCheckboxes />
{/* Reviewer Info Box */}
<div className="rounded-xl bg-slate-50 p-3.5">
<p className="text-xs font-semibold text-slate-800">
{currentImage.submittedBy ?? 'Hà Linh'} đã gửi nhãn {activeClass?.name ?? 'Ô tô'}
</p>
<p className="mt-1 text-[11px] text-slate-500">
{currentImage.submittedAt ?? 'Hôm nay, 09:42'} · Người duyệt:{' '}
{currentImage.reviewerName ?? 'Thu Hà'}
</p>
</div>
{/* Review Actions */}
<ReviewActions approveLabel="Duyệt nhãn" targetStatusOnApprove="completed" />
<p className="text-[11px] text-slate-400">
Enter để duyệt · 1–4 chọn lớp
</p>
</div>
)
}