|
|
|
@ -1,12 +1,15 @@
@@ -1,12 +1,15 @@
|
|
|
|
|
import { Card } from "antd"; |
|
|
|
|
import { Button, Card, Dropdown, Menu, Modal } from "antd"; |
|
|
|
|
import React from "react"; |
|
|
|
|
import { Row } from "../../../components/lib"; |
|
|
|
|
import Mark from "../../../components/Mark"; |
|
|
|
|
import { useDeleteKanban } from "../../../hook/useKanban"; |
|
|
|
|
import { |
|
|
|
|
useTaskModal, |
|
|
|
|
useTasks, |
|
|
|
|
useTasksSearchParmas, |
|
|
|
|
useTasksTypes, |
|
|
|
|
} from "../../../hook/useTask"; |
|
|
|
|
import { Kanban } from "../../../type"; |
|
|
|
|
import { Kanban, Task } from "../../../type"; |
|
|
|
|
import CreateTask from "../CreateTask"; |
|
|
|
|
import { Container, TasksContainer } from "../style"; |
|
|
|
|
|
|
|
|
@ -28,24 +31,64 @@ const TaskTypeIcon = ({ id }: { id: number }) => {
@@ -28,24 +31,64 @@ const TaskTypeIcon = ({ id }: { id: number }) => {
|
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const TaskCard = ({ task }: { task: Task }) => { |
|
|
|
|
const { startEdit } = useTaskModal(); |
|
|
|
|
const { name: keyword } = useTasksSearchParmas(); |
|
|
|
|
return ( |
|
|
|
|
<Card |
|
|
|
|
onClick={() => startEdit(task.id)} |
|
|
|
|
style={{ marginBottom: "0.5rem", cursor: "pointer" }} |
|
|
|
|
key={task.id} |
|
|
|
|
> |
|
|
|
|
<p> |
|
|
|
|
<Mark keyword={keyword} name={task.name} /> |
|
|
|
|
</p> |
|
|
|
|
<TaskTypeIcon id={task.typeId} /> |
|
|
|
|
</Card> |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const More = ({ kanban }: { kanban: Kanban }) => { |
|
|
|
|
const { mutateAsync, isLoading } = useDeleteKanban(); |
|
|
|
|
const startEdit = () => { |
|
|
|
|
Modal.confirm({ |
|
|
|
|
okText: "确定", |
|
|
|
|
cancelText: "取消", |
|
|
|
|
title: "确定删除看板吗?", |
|
|
|
|
onOk: () => { |
|
|
|
|
return mutateAsync({ id: kanban.id }); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
const overlay = ( |
|
|
|
|
<Menu> |
|
|
|
|
<Menu.Item> |
|
|
|
|
<Button type="link" onClick={startEdit}> |
|
|
|
|
删除 |
|
|
|
|
</Button> |
|
|
|
|
</Menu.Item> |
|
|
|
|
</Menu> |
|
|
|
|
); |
|
|
|
|
return ( |
|
|
|
|
<Dropdown overlay={overlay}> |
|
|
|
|
<Button type="link">...</Button> |
|
|
|
|
</Dropdown> |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const KanbanColumn = ({ kanban }: { kanban: Kanban }) => { |
|
|
|
|
const { data: allTasks } = useTasks(useTasksSearchParmas()); |
|
|
|
|
const tasks = allTasks?.filter((task) => task.kanbanId === kanban.id); |
|
|
|
|
const { startEdit } = useTaskModal(); |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<Container> |
|
|
|
|
<h3>{kanban.name}</h3> |
|
|
|
|
<Row between={true}> |
|
|
|
|
<h3>{kanban.name}</h3> |
|
|
|
|
<More kanban={kanban} /> |
|
|
|
|
</Row> |
|
|
|
|
<TasksContainer> |
|
|
|
|
{tasks?.map((task) => ( |
|
|
|
|
<Card |
|
|
|
|
onClick={() => startEdit(task.id)} |
|
|
|
|
style={{ marginBottom: "0.5rem", cursor: "pointer" }} |
|
|
|
|
key={task.id} |
|
|
|
|
> |
|
|
|
|
<div>{task.name}</div> |
|
|
|
|
<TaskTypeIcon id={task.typeId} /> |
|
|
|
|
</Card> |
|
|
|
|
<TaskCard task={task} /> |
|
|
|
|
))} |
|
|
|
|
<CreateTask kanbanId={kanban.id} /> |
|
|
|
|
</TasksContainer> |
|
|
|
|