@@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from 'react';
22
33import { calcDuration , msToTime } from '../helpers/DateTime' ;
44import TaskModel from '../models/TaskModel' ;
5- import TaskTimeModel from '../models/TaskTimeModel ' ;
5+ import TaskTimeItemModel from '../models/TaskTimeItemModel ' ;
66
77export function useTaskDuration ( model : TaskModel | undefined ) {
88 model = model || ( { } as TaskModel ) ;
@@ -33,16 +33,23 @@ export function useTaskDuration(model: TaskModel | undefined) {
3333 return duration ;
3434}
3535
36- export function useTimeItemsDuration ( taskTime : TaskTimeModel [ ] ) {
36+ export function useTimeItemsDuration (
37+ taskTime : TaskTimeItemModel [ ] ,
38+ showSeconds : boolean = false
39+ ) {
3740 const [ duration , setDuration ] = useState < string > ( '' ) ;
3841 const intervalRef = useRef < NodeJS . Timeout > ( ) ;
3942
4043 useEffect ( ( ) => {
4144 const haveActiveTime = taskTime . some ( ( t ) => ! t . time . end ) ;
42- setDuration ( msToTime ( calcDuration ( taskTime . map ( ( t ) => t . time ) ) , false ) ) ;
45+ setDuration (
46+ msToTime ( calcDuration ( taskTime . map ( ( t ) => t . time ) ) , showSeconds )
47+ ) ;
4348 if ( haveActiveTime ) {
4449 intervalRef . current = setInterval ( ( ) => {
45- setDuration ( msToTime ( calcDuration ( taskTime . map ( ( t ) => t . time ) ) , false ) ) ;
50+ setDuration (
51+ msToTime ( calcDuration ( taskTime . map ( ( t ) => t . time ) ) , showSeconds )
52+ ) ;
4653 } , 1000 ) ;
4754 }
4855 return ( ) => {
0 commit comments