import { Button, Card, Descriptions, Progress, Space, Tag, Typography } from '@arco-design/web-react'
import { IconArrowLeft, IconCalendar, IconCheckCircle, IconPlus, IconUser } from '@arco-design/web-react/icon'
import type { ProjectWorkspace, TaskItem } from './project-types'
const { Title, Text } = Typography
export function ProjectTasks({
activeWorkspace,
activeTaskID,
onOpenTask,
onCloseTask,
onSelectItem,
onCreateTask,
}: {
activeWorkspace: ProjectWorkspace
activeTaskID: string | null
onOpenTask: (taskID: string) => void
onCloseTask: () => void
onSelectItem: (title: string) => void
onCreateTask: () => void
}) {
const { tasks, project } = activeWorkspace
const activeTask = tasks.find((task) => task.id === activeTaskID)
const lanes = makeLanes(tasks)
if (activeTask) {
return
}
return (
工作计划
{project.name} 的 TODO 计划、负责人和创建时间。
} onClick={onCreateTask}>新建任务
任务清单
{tasks.length} 个任务
{tasks.map((task) => (
))}
{lanes.map((lane) => (
{lane.title}
{lane.items.length}
{lane.items.map((title) => (
))}
))}
)
}
function TaskDetail({ activeWorkspace, task, onBack }: { activeWorkspace: ProjectWorkspace; task: TaskItem; onBack: () => void }) {
const percent = Number.parseInt(task.progress, 10)
return (
} onClick={onBack}>返回任务列表
{task.title}
{activeWorkspace.project.name} 的任务详情
{task.tag}
任务说明
{task.summary || '暂无任务说明'}
)
}
function openTaskByTitle(tasks: TaskItem[], title: string, onOpenTask: (taskID: string) => void, onSelectItem: (title: string) => void) {
const task = tasks.find((item) => item.title === title)
if (task) {
onOpenTask(task.id)
return
}
onSelectItem(title)
}
function makeLanes(tasks: TaskItem[]) {
const done = tasks.filter((task) => task.completed)
const active = tasks.filter((task) => !task.completed)
return [
{ title: '待开始', color: 'gray', items: active.slice(0, 1).map((task) => task.title) },
{ title: '进行中', color: 'arcoblue', items: active.map((task) => task.title) },
{ title: '已完成', color: 'green', items: done.length ? done.map((task) => task.title) : ['暂无已完成任务'] },
]
}