// Feladatkezelő — projekt-szintű, mindenki által látható közös feladattábla. // A felső sávban a korábbi csapat chat helyét veszi át. Minden szerep látja // és szerkesztheti; törölni csak a létrehozó vagy admin tud. const TASK_STATUSES = [ { key: 'todo', label: 'Teendő', cls: 'todo' }, { key: 'in_progress', label: 'Folyamatban', cls: 'doing' }, { key: 'done', label: 'Kész', cls: 'done' }, ]; const TASK_PRIORITIES = [ { key: 'high', label: 'Magas', cls: 'high' }, { key: 'normal', label: 'Normál', cls: 'normal' }, { key: 'low', label: 'Alacsony', cls: 'low' }, ]; const taskStatusMeta = (k) => TASK_STATUSES.find(s => s.key === k) || TASK_STATUSES[0]; const taskPriorityMeta = (k) => TASK_PRIORITIES.find(p => p.key === k) || TASK_PRIORITIES[1]; // ─── Létrehozó / szerkesztő űrlap ────────────────────────────────────────── const TaskForm = ({ user, task, onClose, onSaved, onDeleted, onToast }) => { const editing = !!task; const [title, setTitle] = React.useState(task?.title || ''); const [description, setDescription] = React.useState(task?.description || ''); const [assigneeId, setAssigneeId] = React.useState(task?.assigneeId ? String(task.assigneeId) : ''); const [status, setStatus] = React.useState(task?.status || 'todo'); const [priority, setPriority] = React.useState(task?.priority || 'normal'); const [dueDate, setDueDate] = React.useState(task?.dueDate || ''); const [tagText, setTagText] = React.useState((task?.tags || []).join(', ')); const [busy, setBusy] = React.useState(false); const canDelete = editing && (task.createdBy === user.id || user.role === 'admin'); const members = window.USERS || []; const submit = async () => { if (!title.trim()) { onToast('Adj címet a feladatnak'); return; } setBusy(true); try { const payload = { title: title.trim(), description: description.trim(), assignee_id: assigneeId ? Number(assigneeId) : null, status, priority, due_date: dueDate || '', tags: tagText, }; if (editing) payload.id = task.id; await window.api.tasks.save(payload); await window.refreshData(); onSaved(editing); } catch (err) { onToast('Hiba: ' + window.apiErrorMessage(err)); } finally { setBusy(false); } }; const remove = async () => { if (!window.confirm('Biztosan törlöd ezt a feladatot?')) return; setBusy(true); try { await window.api.tasks.del(task.id); await window.refreshData(); onDeleted(); } catch (err) { onToast('Hiba: ' + window.apiErrorMessage(err)); } finally { setBusy(false); } }; return (
setTitle(e.target.value)} placeholder="Mi a teendő?" autoFocus maxLength={255}/>