import { Input, Modal, Select, Space, Switch, Typography } from '@arco-design/web-react' import { useEffect, useMemo, useState } from 'react' import type { ProjectWorkspace, TaskItem } from './project-types' const { Text } = Typography const { TextArea } = Input export type ProjectTaskUpdate = { taskId: string title: string summary: string tag: string completed: boolean } type TaskDraft = { title: string summary: string tag: string completed: boolean } export function ProjectTaskEditModal({ task, workspace, onClose, onSubmit, }: { task: TaskItem | null workspace: ProjectWorkspace onClose: () => void onSubmit: (update: ProjectTaskUpdate) => void }) { const tagOptions = useMemo(() => workspace.tags.filter((tag) => tag !== 'all' && tag !== '全部'), [workspace.tags]) const [draft, setDraft] = useState({ title: '', summary: '', tag: '', completed: false }) useEffect(() => { if (!task) return setDraft({ title: task.title, summary: task.summary, tag: task.tag, completed: task.completed, }) }, [task]) return ( { if (!task) return onSubmit({ taskId: task.id, title: draft.title.trim() || task.title, summary: draft.summary.trim(), tag: draft.tag.trim(), completed: draft.completed, }) }} >