Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit 30e727a

Browse files
author
Dmitry Yadrikhinsky
committed
[HoursCard] Duration, project name, description
1 parent 38b8896 commit 30e727a

File tree

3 files changed

+45
-12
lines changed

3 files changed

+45
-12
lines changed

src/components/PlayStopButton/PlayStopButton.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@ import './PlayStopButton.less';
66
import CircleButton from '../CircleButton/CircleButton';
77
import rootStore from '../../services/RootStore';
88
import TaskModel from '../../models/TaskModel';
9+
import cn from '../../helpers/ClassNameHelper';
910

1011
const { tasksStore } = rootStore;
1112

1213
interface PlayStopButtonProps {
1314
task: TaskModel | undefined;
15+
className?: string;
1416
}
1517

16-
export default function PlayStopButton({ task }: PlayStopButtonProps) {
18+
export default function PlayStopButton({
19+
task,
20+
className,
21+
}: PlayStopButtonProps) {
1722
function handleClick(e: SyntheticEvent) {
1823
e.stopPropagation();
1924
if (task) {
@@ -26,7 +31,10 @@ export default function PlayStopButton({ task }: PlayStopButtonProps) {
2631
}
2732

2833
return (
29-
<CircleButton onClick={handleClick} className="play-stop-button">
34+
<CircleButton
35+
onClick={handleClick}
36+
className={cn('play-stop-button', className)}
37+
>
3038
{!task?.active ? (
3139
<CaretRightFilled className="play-stop-button__icon" />
3240
) : (

src/screens/hours/components/HoursCard/HoursCard.less

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,34 @@
1111
cursor: pointer;
1212
}
1313

14-
.hours-card__title {
15-
font-weight: bold;
14+
.project-title {
1615
font-size: 12px;
1716
}
1817

19-
.hours-card__description {
18+
.task-title {
19+
font-weight: bold;
2020
font-size: 12px;
2121
}
2222

23-
.hours-card__time {
23+
.description {
24+
font-size: 11px;
25+
}
26+
27+
.time-container {
28+
display: flex;
29+
flex-direction: row;
30+
justify-content: space-between;
31+
margin-top: 8px;
32+
}
33+
34+
.time {
2435
font-size: 11px;
2536
}
2637

2738
.play-stop-button {
2839
display: none;
40+
position: absolute;
41+
right: 8px;
2942
}
3043

3144
&:hover .play-stop-button {

src/screens/hours/components/HoursCard/HoursCard.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useEffect, useMemo } from 'react';
22
import { Card } from 'antd';
33
import format from 'date-fns/format';
44
import { observer } from 'mobx-react';
@@ -7,6 +7,10 @@ import './HoursCard.less';
77

88
import TaskTimeModel from '../../../../models/TaskTimeModel';
99
import PlayStopButton from '../../../../components/PlayStopButton/PlayStopButton';
10+
import rootStore from '../../../../services/RootStore';
11+
import { msToTime } from '../../../../helpers/DateTime';
12+
13+
const { projectStore } = rootStore;
1014

1115
const formatStr = 'HH:mm';
1216
function timeFormat(date: Date | undefined) {
@@ -26,15 +30,23 @@ export default observer(function HoursCard({
2630
onClick,
2731
}: HoursCardProps) {
2832
const { task, time } = taskTime;
33+
const project = useMemo(() => projectStore.get(task.projectId), [task]);
34+
const duration = time.end
35+
? msToTime(time.end.getTime() - time.start.getTime())
36+
: '';
2937

3038
return (
3139
<Card className="hours-card" onClick={() => onClick(taskTime)}>
3240
<div className="hours-card__info">
33-
<div className="hours-card__title">{task.title}</div>
34-
<div className="hours-card__description">{time.description}</div>
35-
<div className="hours-card__time">{`${timeFormat(
36-
time.start
37-
)} - ${timeFormat(time.end)}`}</div>
41+
<div className="project-title">{project?.title}</div>
42+
<div className="task-title">{task.title}</div>
43+
<div className="description">{time.description}</div>
44+
<div className="time-container">
45+
<div className="time">{`${timeFormat(time.start)} - ${timeFormat(
46+
time.end
47+
)}`}</div>
48+
<div className="time">{duration}</div>
49+
</div>
3850
</div>
3951
<PlayStopButton task={task} />
4052
</Card>

0 commit comments

Comments
 (0)