Skip to content

Commit 02e99fa

Browse files
author
Dmitry Yadrikhinsky
committed
Move duration
1 parent fc8b262 commit 02e99fa

File tree

3 files changed

+34
-16
lines changed

3 files changed

+34
-16
lines changed

src/components/PlayStopButton/PlayStopButton.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { SyntheticEvent } from 'react';
22
import { CaretRightFilled, PauseOutlined } from '@ant-design/icons';
3+
import { observer } from 'mobx-react';
34

45
import './PlayStopButton.less';
56

@@ -15,7 +16,7 @@ interface PlayStopButtonProps {
1516
className?: string;
1617
}
1718

18-
export default function PlayStopButton({
19+
export default observer(function PlayStopButton({
1920
task,
2021
className,
2122
}: PlayStopButtonProps) {
@@ -42,4 +43,4 @@ export default function PlayStopButton({
4243
)}
4344
</CircleButton>
4445
);
45-
}
46+
});

src/screens/projects/components/DrawerTask/DrawerTask.tsx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import React, { useMemo } from 'react';
22
import { Checkbox, Drawer, Input, Space } from 'antd';
33
import { observer } from 'mobx-react';
4-
import { ClockCircleOutlined, ProjectOutlined } from '@ant-design/icons';
4+
import { ProjectOutlined } from '@ant-design/icons';
55

66
import './DrawerTask.less';
77

88
import TaskModel from '../../../../models/TaskModel';
99
import rootStore from '../../../../services/RootStore';
10-
import { useTaskDuration } from '../../../../hooks/TaskHooks';
1110
import HoursByTask from '../HoursByTask/HoursByTask';
1211
import IconTile from '../../../../components/IconTile/IconTile';
13-
import CircleButton from '../../../../components/CircleButton/CircleButton';
14-
import PlayStopButton from '../../../../components/PlayStopButton/PlayStopButton';
12+
import Duration from './components/Duration';
1513

1614
const { projectStore } = rootStore;
1715

@@ -29,8 +27,6 @@ export default observer(function DrawerTask({
2927
const project = useMemo(() => projectStore.get(task?.projectId || ''), [
3028
task,
3129
]);
32-
const duration = useTaskDuration(task);
33-
3430
return (
3531
<Drawer
3632
placement="right"
@@ -76,14 +72,8 @@ export default observer(function DrawerTask({
7672
}
7773
}}
7874
/>
79-
<div className="icon-with-value">
80-
<IconTile backgroundColor="#713A91">
81-
<ClockCircleOutlined style={{ color: 'white ' }} />
82-
</IconTile>
83-
<span className="value">{duration}</span>
84-
<span className="flex-1" />
85-
<PlayStopButton task={task} />
86-
</div>
75+
76+
<Duration task={task} />
8777

8878
<HoursByTask task={task} />
8979
</Space>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
import { ClockCircleOutlined } from '@ant-design/icons';
3+
import { observer } from 'mobx-react';
4+
5+
import IconTile from '../../../../../components/IconTile/IconTile';
6+
import PlayStopButton from '../../../../../components/PlayStopButton/PlayStopButton';
7+
import TaskModel from '../../../../../models/TaskModel';
8+
import { useTaskDuration } from '../../../../../hooks/TaskHooks';
9+
10+
interface DurationProps {
11+
task?: TaskModel;
12+
}
13+
14+
export default observer(function Duration({ task }: DurationProps) {
15+
const duration = useTaskDuration(task);
16+
17+
return (
18+
<div className="icon-with-value">
19+
<IconTile backgroundColor="#713A91">
20+
<ClockCircleOutlined style={{ color: 'white ' }} />
21+
</IconTile>
22+
<span className="value">{duration}</span>
23+
<span className="flex-1" />
24+
<PlayStopButton task={task} />
25+
</div>
26+
);
27+
});

0 commit comments

Comments
 (0)