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 = ({ isOpen, onClose, onInvite, }) => { const [email, setEmail] = useState('') const [role, setRole] = useState('annotator') const [selectedProjects, setSelectedProjects] = useState([ 'proj-1', 'proj-2', 'proj-3', ]) const [error, setError] = useState(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 (
{/* Modal Header */}

Mời người dùng mới

Gửi lời mời tham gia không gian nhóm danable qua email công việc.

{/* Form Body */}
{error && (
{error}
)} {/* Email */}
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]" />
{/* Role Selection */}
{( [ { 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 ( ) })}
{/* Project Assignment Checkboxes */}
{AVAILABLE_PROJECTS.map((proj) => { const checked = selectedProjects.includes(proj.id) return ( ) })}
{/* Footer Buttons */}
) } export default InviteUserModal