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,120 @@
import React, { useState, useRef, useEffect } from 'react'
interface NotificationItem {
id: string
title: string
time: string
unread?: boolean
}
const MOCK_NOTIFICATIONS: NotificationItem[] = [
{
id: 'n1',
title: 'Hà Linh đã gửi 18 ảnh chờ duyệt trong dự án Giao thông đô thị',
time: '5 phút trước',
unread: true,
},
{
id: 'n2',
title: 'Tuấn Nam hoàn thành gán nhãn lô #04 (120 ảnh)',
time: '1 giờ trước',
unread: true,
},
{
id: 'n3',
title: 'Xuất bộ nhãn YOLOv8 thành công',
time: 'Hôm qua',
unread: false,
},
]
export const NotificationBell: React.FC = () => {
const [open, setOpen] = useState(false)
const [notifications, setNotifications] = useState(MOCK_NOTIFICATIONS)
const ref = useRef<HTMLDivElement>(null)
useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
if (ref.current && !ref.current.contains(event.target as Node)) {
setOpen(false)
}
}
document.addEventListener('mousedown', handleClickOutside)
return () => document.removeEventListener('mousedown', handleClickOutside)
}, [])
const unreadCount = notifications.filter((n) => n.unread).length
const markAllRead = () => {
setNotifications((prev) => prev.map((n) => ({ ...n, unread: false })))
}
return (
<div ref={ref} className="relative">
<button
type="button"
onClick={() => setOpen((prev) => !prev)}
className="relative rounded-full p-2 text-slate-500 hover:bg-slate-100 hover:text-slate-800 transition-colors"
aria-label="Thông báo"
>
<svg
className="h-4 w-4"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
strokeWidth={1.9}
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"
/>
</svg>
{unreadCount > 0 && (
<span className="absolute top-1.5 right-1.5 h-2 w-2 rounded-full bg-[#C95C3C] ring-2 ring-white" />
)}
</button>
{open && (
<div className="absolute right-0 z-50 mt-2 w-80 rounded-2xl border border-slate-200 bg-white shadow-xl overflow-hidden">
<div className="flex items-center justify-between border-b border-slate-100 px-4 py-3">
<span className="text-xs font-semibold text-slate-900">
Thông báo ({unreadCount})
</span>
{unreadCount > 0 && (
<button
type="button"
onClick={markAllRead}
className="text-[11px] font-medium text-[#C95C3C] hover:underline"
>
Đánh dấu đã đọc
</button>
)}
</div>
<div className="divide-y divide-slate-100 max-h-72 overflow-y-auto">
{notifications.map((item) => (
<div
key={item.id}
className="px-4 py-3 hover:bg-slate-50 transition-colors"
>
<div className="flex items-start gap-2">
{item.unread && (
<span className="mt-1.5 h-1.5 w-1.5 rounded-full bg-[#C95C3C] shrink-0" />
)}
<div>
<p className="text-xs text-slate-700 leading-relaxed">
{item.title}
</p>
<span className="mt-1 block text-[11px] text-slate-400">
{item.time}
</span>
</div>
</div>
</div>
))}
</div>
</div>
)}
</div>
)
}