import React from 'react';
import {
Timeline, Drawer, Empty, Button, Space, Typography, Popover,
} from 'antd';
import {
ClockCircleOutlined,
PlusCircleOutlined,
InfoCircleOutlined,
PauseCircleOutlined,
MedicineBoxOutlined,
} from '@ant-design/icons';
const { Paragraph } = Typography;
class TaskList extends React.Component {
state = {
tasks: [],
showAll: false,
}
constructor(props) {
super(props);
this.state.tasks = this.props.tasks.map(item => false);
}
render() {
return this.createTaskList(4);
}
createTaskList(maxNumberOfTasks) {
const tasks = this.props.tasks.slice(0, maxNumberOfTasks);
return (
<>
{this.props.tasks && this.props.tasks.length > 0
&& (
{tasks.map(
(task, index) => (
this.createTask(task, index)
),
)}
{this.props.tasks.length > maxNumberOfTasks &&
}
)}
{this.props.tasks && this.props.tasks.length === 0
&& }
this.hideAllTasks()}
visible={this.state.showAll}
bodyStyle={{ paddingBottom: 80 }}
zIndex={1200}
maskClosable={false}
>
{this.props.tasks.map(
(task, index) => (
this.createTask(task, index)
),
)}
>
);
}
visitLink(link) {
setTimeout(() => {window.open(link);}, 100);
}
handleTaskHover(index) {
this.setState({tasks : this.props.tasks.map((item,i) => index === i)})
}
createTask(task, index) {
if (task.priority === 100) {
return (
this.handleTaskHover(index)}
dot={} color="red" >
{this.getText(task)}
{task.link && this.state.tasks[index]
&& (
)}
);
} if (task.priority === 50) {
return (
this.handleTaskHover(index)}
dot={} color="blue">
{this.getText(task)}
{task.link && this.state.tasks[index]
&& (
)}
);
} if (task.priority === 20) {
return (
this.handleTaskHover(index)}
dot={} color="blue">
{this.getText(task)}
{task.link && this.state.tasks[index]
&& (
)}
);
} if (task.priority === 10) {
return (
this.handleTaskHover(index)}
dot={} color="green">
{this.getText(task)}
{task.link && this.state.tasks[index]
&& (
)}
);
}
}
getText(task) {
if (!task.details) {
return (
{task.text}
);
}
return (
{task.text}
);
}
showAllTasks() {
this.setState({showAll: true});
}
hideAllTasks() {
this.setState({showAll: false});
}
}
export default TaskList;