import { useState } from "react"; import type { Task } from "@/lib/api"; import { createTask } from "@/lib/api"; const PRIORITIES = [ { key: "low", label: "Low", color: "#737373" }, { key: "medium", label: "Medium", color: "#3b82f6" }, { key: "high", label: "High", color: "#f59e0b" }, { key: "critical", label: "Critical", color: "#ef4444" }, ]; interface Props { projectSlug: string; initialStatus: string; onClose: () => void; onCreated: (task: Task) => void; } export default function CreateTaskModal({ projectSlug, initialStatus, onClose, onCreated }: Props) { const [title, setTitle] = useState(""); const [description, setDescription] = useState(""); const [priority, setPriority] = useState("medium"); const [saving, setSaving] = useState(false); const [error, setError] = useState(""); const handleSubmit = async () => { if (!title.trim()) return; setSaving(true); setError(""); try { const task = await createTask(projectSlug, { title: title.trim(), description: description.trim() || undefined, status: initialStatus, priority, }); onCreated(task); onClose(); } catch (e: any) { setError(e.message || "Ошибка"); } finally { setSaving(false); } }; return (
e.stopPropagation()} >

Новая задача

setTitle(e.target.value)} onKeyDown={(e) => e.key === "Enter" && handleSubmit()} placeholder="Название задачи..." className="w-full bg-[var(--bg)] border border-[var(--border)] rounded-lg px-3 py-2 text-sm outline-none focus:border-[var(--accent)]" />