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
199
src/pages/users/components/InviteUserModal.tsx
Normal file
199
src/pages/users/components/InviteUserModal.tsx
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
import React, { useState } from 'react'
|
||||
import { InviteMemberInput, UserRole } from '../../../types'
|
||||
|
||||
export interface InviteUserModalProps {
|
||||
isOpen: boolean
|
||||
onClose: () => void
|
||||
onInvite: (input: InviteMemberInput) => void
|
||||
}
|
||||
|
||||
const AVAILABLE_PROJECTS = [
|
||||
{ id: 'proj-1', name: 'Phương tiện đô thị', count: '1.850 ảnh' },
|
||||
{ id: 'proj-2', name: 'Giao thông đô thị', count: '1.420 ảnh' },
|
||||
{ id: 'proj-3', name: 'Phân vùng đường phố', count: '1.050 ảnh' },
|
||||
]
|
||||
|
||||
export const InviteUserModal: React.FC<InviteUserModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
onInvite,
|
||||
}) => {
|
||||
const [email, setEmail] = useState('')
|
||||
const [role, setRole] = useState<UserRole>('annotator')
|
||||
const [selectedProjects, setSelectedProjects] = useState<string[]>([
|
||||
'proj-1',
|
||||
'proj-2',
|
||||
'proj-3',
|
||||
])
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
if (!isOpen) return null
|
||||
|
||||
const toggleProject = (id: string) => {
|
||||
setSelectedProjects((prev) =>
|
||||
prev.includes(id) ? prev.filter((item) => item !== id) : [...prev, id]
|
||||
)
|
||||
}
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault()
|
||||
if (!email.trim() || !email.includes('@')) {
|
||||
setError('Vui lòng nhập địa chỉ email hợp lệ.')
|
||||
return
|
||||
}
|
||||
setError(null)
|
||||
onInvite({
|
||||
email: email.trim(),
|
||||
role,
|
||||
projectIds: selectedProjects,
|
||||
})
|
||||
setEmail('')
|
||||
setRole('annotator')
|
||||
onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40 backdrop-blur-[1px] p-4">
|
||||
<div className="bg-white rounded-2xl max-w-lg w-full border border-slate-200 shadow-xl overflow-hidden">
|
||||
{/* Modal Header */}
|
||||
<div className="flex items-center justify-between px-6 py-4 border-b border-slate-200">
|
||||
<div>
|
||||
<h3 className="text-base font-bold text-slate-900">
|
||||
Mời người dùng mới
|
||||
</h3>
|
||||
<p className="text-xs text-slate-500 mt-0.5">
|
||||
Gửi lời mời tham gia không gian nhóm danable qua email công việc.
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="p-1.5 rounded-lg text-slate-400 hover:text-slate-700 hover:bg-slate-100"
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Form Body */}
|
||||
<form onSubmit={handleSubmit} className="p-6 space-y-5">
|
||||
{error && (
|
||||
<div className="px-3.5 py-2.5 rounded-xl bg-rose-50 border border-rose-200 text-xs text-rose-700">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Email */}
|
||||
<div>
|
||||
<label className="block text-xs font-semibold text-slate-800 mb-1.5">
|
||||
Email công việc
|
||||
</label>
|
||||
<input
|
||||
type="email"
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
placeholder="thanhvien@visionlab.vn"
|
||||
className="w-full px-3.5 py-2.5 rounded-xl border border-slate-200 text-sm text-slate-900 focus:outline-none focus:border-[#C95C3C]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Role Selection */}
|
||||
<div>
|
||||
<label className="block text-xs font-semibold text-slate-800 mb-2">
|
||||
Vai trò trong nhóm
|
||||
</label>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-3 gap-2.5">
|
||||
{(
|
||||
[
|
||||
{
|
||||
value: 'annotator',
|
||||
title: 'Người gán nhãn',
|
||||
desc: 'Tạo & sửa nhãn',
|
||||
},
|
||||
{
|
||||
value: 'reviewer',
|
||||
title: 'Người duyệt',
|
||||
desc: 'Duyệt & trả lại nhãn',
|
||||
},
|
||||
{
|
||||
value: 'manager',
|
||||
title: 'Quản lý',
|
||||
desc: 'Quản lý & phân công',
|
||||
},
|
||||
] as const
|
||||
).map((item) => {
|
||||
const active = role === item.value
|
||||
return (
|
||||
<button
|
||||
key={item.value}
|
||||
type="button"
|
||||
onClick={() => setRole(item.value)}
|
||||
className={`text-left p-3 rounded-xl border transition-all ${
|
||||
active
|
||||
? 'border-[#C95C3C] bg-[#FDF4F1] ring-1 ring-[#C95C3C]'
|
||||
: 'border-slate-200 bg-white hover:bg-slate-50'
|
||||
}`}
|
||||
>
|
||||
<div className="text-xs font-bold text-slate-900">
|
||||
{item.title}
|
||||
</div>
|
||||
<div className="text-[11px] text-slate-500 mt-0.5">
|
||||
{item.desc}
|
||||
</div>
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Project Assignment Checkboxes */}
|
||||
<div>
|
||||
<label className="block text-xs font-semibold text-slate-800 mb-2">
|
||||
Dự án được phân công
|
||||
</label>
|
||||
<div className="space-y-2 rounded-xl border border-slate-200 p-3 bg-slate-50/50">
|
||||
{AVAILABLE_PROJECTS.map((proj) => {
|
||||
const checked = selectedProjects.includes(proj.id)
|
||||
return (
|
||||
<label
|
||||
key={proj.id}
|
||||
className="flex items-center justify-between text-xs text-slate-800 cursor-pointer py-1 px-1"
|
||||
>
|
||||
<span className="inline-flex items-center gap-2.5 font-medium">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={checked}
|
||||
onChange={() => toggleProject(proj.id)}
|
||||
className="w-4 h-4 rounded border-slate-300 accent-[#C95C3C]"
|
||||
/>
|
||||
<span>{proj.name}</span>
|
||||
</span>
|
||||
<span className="text-slate-400">{proj.count}</span>
|
||||
</label>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Footer Buttons */}
|
||||
<div className="flex items-center justify-end gap-2.5 pt-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="px-4 py-2.5 rounded-xl border border-slate-200 bg-white text-xs font-semibold text-slate-700 hover:bg-slate-50"
|
||||
>
|
||||
Hủy
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
className="px-4 py-2.5 rounded-xl bg-[#C95C3C] hover:bg-[#B5492B] text-white text-xs font-semibold shadow-sm transition-colors"
|
||||
>
|
||||
Gửi lời mời
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default InviteUserModal
|
||||
Loading…
Add table
Add a link
Reference in a new issue