|
| 1 | +import React from 'react'; |
| 2 | +import cn from "classnames"; |
| 3 | +import { Card, Steps, Typography, Divider } from "antd"; |
| 4 | +import { UserOutlined, HomeOutlined } from "@ant-design/icons"; |
| 5 | +import { useFetch } from "shared/hooks"; |
| 6 | +import "./index.scss"; |
| 7 | + |
| 8 | +type Props = Task; |
| 9 | + |
| 10 | +const ICON_STYLE = { color: '#08c' }; |
| 11 | + |
| 12 | +const getTaskStatus = (completed: boolean) => { |
| 13 | + if (completed) return 1; |
| 14 | + return 0; |
| 15 | +}; |
| 16 | + |
| 17 | +// TODO: as feature |
| 18 | +const TaskCard = (props: Props) => { |
| 19 | + const { completed, id, title, userId } = props; |
| 20 | + const { data: author } = useFetch<User>(`users/${userId}`); |
| 21 | + |
| 22 | + return ( |
| 23 | + <Card |
| 24 | + className={cn("task-card", { completed })} |
| 25 | + title={`Task - ${title}`} |
| 26 | + > |
| 27 | + <div className="task-card__details"> |
| 28 | + <i className="text-muted">Task description</i> |
| 29 | + </div> |
| 30 | + <div className="task-card__sidebar"> |
| 31 | + <div className="task-card__author"> |
| 32 | + <Typography.Title level={5}>Author</Typography.Title> |
| 33 | + <span className="task-card__author" > |
| 34 | + <UserOutlined style={ICON_STYLE} /> {author?.username} {`<${author?.email}>`} |
| 35 | + <br /> |
| 36 | + <HomeOutlined style={ICON_STYLE} /> {author?.company.name} |
| 37 | + </span> |
| 38 | + </div> |
| 39 | + <Divider /> |
| 40 | + <div className="task-card__status"> |
| 41 | + <Typography.Title level={5}>Status</Typography.Title> |
| 42 | + <Steps direction="vertical" current={getTaskStatus(completed)}> |
| 43 | + <Steps.Step title="Created" description="Task was created and added in todo-list." /> |
| 44 | + <Steps.Step title="Finished" description="Task was completed by author." /> |
| 45 | + </Steps> |
| 46 | + </div> |
| 47 | + </div> |
| 48 | + </Card> |
| 49 | + ) |
| 50 | +} |
| 51 | + |
| 52 | +export default TaskCard |
0 commit comments