import { useState } from "react"; import { useMutation } from "@tanstack/react-query"; import { Plus } from "lucide-react"; import { sstcApi } from "@/api/sstc"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; interface SelectedCharterLike { id: string; } interface SSTCTaskCreateDialogProps { projectId: string; stageLocked: boolean; selectedCharter: SelectedCharterLike | null; onRefresh: () => Promise | void; } export function SSTCTaskCreateDialog({ projectId, stageLocked, selectedCharter, onRefresh, }: SSTCTaskCreateDialogProps) { const [newTaskOpen, setNewTaskOpen] = useState(false); const [newTaskTitle, setNewTaskTitle] = useState(""); const [newTaskDesc, setNewTaskDesc] = useState(""); const [newTaskPriority, setNewTaskPriority] = useState("medium"); const [newTaskHours, setNewTaskHours] = useState(""); const [newTaskDueDate, setNewTaskDueDate] = useState(""); const createTaskMutation = useMutation({ mutationFn: () => sstcApi.createTask(projectId, selectedCharter!.id, { title: newTaskTitle, description: newTaskDesc || undefined, priority: newTaskPriority, estimated_hours: newTaskHours ? Number(newTaskHours) : undefined, due_date: newTaskDueDate || undefined, }), onSuccess: () => { setNewTaskOpen(false); setNewTaskTitle(""); setNewTaskDesc(""); setNewTaskHours(""); setNewTaskDueDate(""); onRefresh(); }, }); return ( <> 新建任务 任务将绑定当前宪章(SSTC 强制)
setNewTaskTitle(e.target.value)} placeholder="任务标题" />