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

Commit 57ea3a5

Browse files
committed
[ProgressBar] fixes
1 parent a841897 commit 57ea3a5

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/components/ProgressBar.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,30 @@ function ProgressBar() {
5353
timeItems,
5454
]);
5555

56-
const { estimatedWorkingTimeEnd, progress } = TaskTimeService.getDayProgress(
56+
const {
57+
estimatedWorkingTimeEnd,
58+
progress,
59+
realProgress,
60+
} = TaskTimeService.getDayProgress(
5761
timeRangeItems,
5862
workingTimeStart,
5963
workingHoursMs
6064
);
6165

62-
const progressRound = Math.round(progress);
6366
const marks: Record<number, string> = {
6467
0: toTimeFormat(workingTimeStart),
6568
100: toTimeFormat(estimatedWorkingTimeEnd),
6669
};
67-
if (progressRound > 10 && progressRound < 90) {
68-
marks[progressRound] = `${progressRound}%`;
70+
if (progress > 10 && progress < 90) {
71+
marks[progress] = `${realProgress}%`;
6972
}
7073

7174
const tipFormatter = useMemo(() => {
72-
if (progressRound <= 10 || progressRound >= 90) {
73-
return (value?: number) => `${value}%`;
75+
if (progress <= 10 || progress >= 90) {
76+
return () => `${realProgress}%`;
7477
}
7578
return null;
76-
}, [progressRound]);
79+
}, [progress, realProgress]);
7780

7881
return (
7982
<Slider

src/services/TaskTimeService.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ITimeRangeModel } from '../modules/tasks/models/TaskModel';
77

88
export type DayProgress = {
99
progress: number;
10+
realProgress: number;
1011
durationMs: number;
1112
restMs: number;
1213
estimatedWorkingTimeEnd: Date | undefined;
@@ -21,6 +22,7 @@ const TaskTimeService = {
2122
if (!workingTimeStart) {
2223
return {
2324
progress: 0,
25+
realProgress: 0,
2426
durationMs: 0,
2527
restMs: 0,
2628
estimatedWorkingTimeEnd: undefined,
@@ -36,15 +38,19 @@ const TaskTimeService = {
3638
);
3739

3840
let progress = 0;
41+
let realProgress = 0;
3942
if (estimatedWorkingTimeEnd) {
4043
const durationWorkDayMs =
4144
estimatedWorkingTimeEnd.getTime() - workingTimeStart.getTime() || 1;
4245
progress = ((durationMs + restMs) * 100) / durationWorkDayMs;
43-
progress = Math.min(progress, 100);
46+
progress = Math.min(Math.round(progress), 100);
47+
realProgress = (durationMs * 100) / workingHoursMs;
48+
realProgress = Math.min(Math.round(realProgress), 100);
4449
}
4550

4651
return {
4752
progress,
53+
realProgress,
4854
durationMs,
4955
restMs,
5056
estimatedWorkingTimeEnd,

0 commit comments

Comments
 (0)