Skip to content

Commit c27df9f

Browse files
committed
Using hours
1 parent 4860cda commit c27df9f

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/helpers/DateTime.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,12 @@ export function getTime(date: Date | undefined) {
9090
return format(date, TIME_FORMAT);
9191
}
9292

93-
export const EIGHT_HOURS = 8 * 60 * 60 * 1000;
94-
9593
export function estimateWorkingTimeEnd(
9694
startDate: Date | undefined,
97-
restTimeMs: number
95+
restTimeMs: number,
96+
workingHoursMs: number
9897
): Date | undefined {
9998
return startDate
100-
? new Date(startDate.getTime() + restTimeMs + EIGHT_HOURS)
99+
? new Date(startDate.getTime() + restTimeMs + workingHoursMs)
101100
: undefined;
102101
}

src/screens/hours/components/TotalHours/TotalHours.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,34 @@ import { observer } from 'mobx-react';
33
import { Space } from 'antd';
44

55
import * as TaskHooks from '../../../../hooks/TaskHooks';
6-
import TaskTimeItemModel from '../../../../models/TaskTimeItemModel';
6+
import TaskTimeItemModel from '../../../../modules/tasks/models/TaskTimeItemModel';
77
import {
8-
EIGHT_HOURS,
98
estimateWorkingTimeEnd,
109
getTime,
1110
msToTime,
1211
} from '../../../../helpers/DateTime';
1312
import LabelWithTooltip, { ILabelWithTooltipProps } from './LabelWithTooltip';
13+
import rootStore from '../../../../modules/RootStore';
1414

1515
interface TotalHoursProps {
1616
timeItems: TaskTimeItemModel[];
1717
}
1818

19+
const { settingsStore } = rootStore;
20+
1921
const TotalHours = observer((props: TotalHoursProps) => {
2022
const { timeItems } = props;
23+
const { settings } = settingsStore;
24+
const workingHoursMs = settings.numberOfWorkingHours;
2125

2226
const { durationMs, restMs } = TaskHooks.useTimeItemsDuration(timeItems);
2327
const startWorkingTime = TaskHooks.useStartWorkingTime(timeItems);
2428
const estimatedWorkingTimeEnd = estimateWorkingTimeEnd(
2529
startWorkingTime,
26-
restMs
30+
restMs,
31+
workingHoursMs
2732
);
28-
const restHoursMs = EIGHT_HOURS - durationMs;
33+
const restHoursMs = workingHoursMs - durationMs;
2934

3035
if (!timeItems.length) {
3136
return null;

0 commit comments

Comments
 (0)