feat: scaffold complete danable frontend architecture with all pages, layouts, stores, and 3 annotator modes
This commit is contained in:
commit
78848dd7d1
173 changed files with 18649 additions and 0 deletions
60
src/pages/projects/components/detail/StatusCards.tsx
Normal file
60
src/pages/projects/components/detail/StatusCards.tsx
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import React from 'react'
|
||||
import { ProjectStats } from '@/types'
|
||||
|
||||
interface StatusCardsProps {
|
||||
stats: ProjectStats
|
||||
}
|
||||
|
||||
export const StatusCards: React.FC<StatusCardsProps> = ({ stats }) => {
|
||||
const total = stats.totalImages || 1
|
||||
const calcPercent = (val: number) => {
|
||||
const raw = (val / total) * 100
|
||||
// Match exact formatting like 18,75%, 6,25%, 10%, 65%
|
||||
const formatted = Number.isInteger(raw)
|
||||
? raw.toString()
|
||||
: Number(raw.toFixed(2)).toString().replace('.', ',')
|
||||
return `${formatted}%`
|
||||
}
|
||||
|
||||
const formatNum = (n: number) => n.toLocaleString('vi-VN')
|
||||
|
||||
const cards = [
|
||||
{
|
||||
label: 'Chưa gán nhãn',
|
||||
value: formatNum(stats.unassigned),
|
||||
subtext: `${calcPercent(stats.unassigned)} · sẵn sàng phân công`,
|
||||
},
|
||||
{
|
||||
label: 'Đang làm',
|
||||
value: formatNum(stats.inProgress),
|
||||
subtext: `${calcPercent(stats.inProgress)} · nhãn đang soạn`,
|
||||
},
|
||||
{
|
||||
label: 'Chờ duyệt',
|
||||
value: formatNum(stats.pendingReview),
|
||||
subtext: `${calcPercent(stats.pendingReview)} · đã gửi kiểm tra`,
|
||||
},
|
||||
{
|
||||
label: 'Hoàn thành',
|
||||
value: formatNum(stats.completed),
|
||||
subtext: `${calcPercent(stats.completed)} · đã được duyệt`,
|
||||
},
|
||||
]
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||
{cards.map((c) => (
|
||||
<div
|
||||
key={c.label}
|
||||
className="rounded-2xl border border-slate-200/80 bg-white px-5 py-4 shadow-[0_1px_2px_rgba(15,23,42,0.03)]"
|
||||
>
|
||||
<p className="text-xs font-medium text-slate-500">{c.label}</p>
|
||||
<p className="mt-2 text-[28px] font-bold leading-tight tracking-tight text-slate-900">
|
||||
{c.value}
|
||||
</p>
|
||||
<p className="mt-2 text-xs text-slate-500">{c.subtext}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue