@@ -8,37 +8,39 @@ import { useState } from "react";
88import { useIntl } from "react-intl" ;
99import { TIssue } from "../../api/redmine/types" ;
1010import { LocalIssue } from "../../hooks/useLocalIssues" ;
11- import { TimerController } from "../../hooks/useTimers" ;
11+ import { Timer } from "../../hooks/useTimers" ;
1212import { useSettings } from "../../provider/SettingsProvider" ;
13+ import { useTimerApi } from "../../provider/TimerApiProvider" ;
1314import { clsxm } from "../../utils/clsxm" ;
1415import HelpTooltip from "../general/HelpTooltip" ;
1516import { ToggleableCard } from "../general/ToggleableCard" ;
16- import Timer from "../timer/timer" ;
17+ import { TimerComponents } from "../timer/timer" ;
1718import { IssueTitle , IssueTitleSkeleton } from "./IssueTitle" ;
1819
1920type PropTypes = {
2021 issue : TIssue ;
2122 localIssue : LocalIssue ;
2223 priorityType : PriorityType ;
2324 assignedToMe : boolean ;
24- timers : TimerController [ ] ;
25- onAddTimer : ( ) => void ;
25+ timers : Timer [ ] ;
2626} ;
2727
28- const Issue = ( { issue, localIssue, priorityType, assignedToMe, timers, onAddTimer } : PropTypes ) => {
28+ const Issue = ( { issue, localIssue, priorityType, assignedToMe, timers } : PropTypes ) => {
2929 const { formatMessage } = useIntl ( ) ;
3030
3131 const { settings } = useSettings ( ) ;
3232
3333 const { hasProjectPermission } = usePermissions ( ) ;
3434 const canLogTime = hasProjectPermission ( issue . project . id , "log_time" ) ;
3535
36+ const timerApi = useTimerApi ( ) ;
37+
3638 const primaryTimer = timers [ 0 ] ! ;
3739
3840 const [ areTimersExpanded , setAreTimersExpanded ] = useState ( false ) ;
3941
4042 return (
41- < IssueContextMenu issue = { issue } localIssue = { localIssue } primaryTimer = { primaryTimer } assignedToMe = { assignedToMe } onAddTimer = { onAddTimer } >
43+ < IssueContextMenu issue = { issue } localIssue = { localIssue } primaryTimer = { primaryTimer } assignedToMe = { assignedToMe } >
4244 < ToggleableCard
4345 role = "listitem"
4446 data-type = "issue"
@@ -50,7 +52,7 @@ const Issue = ({ issue, localIssue, priorityType, assignedToMe, timers, onAddTim
5052 "border-priority-high-bg ring-priority-high-bg ring-1" : priorityType === "high" || priorityType === "highest" ,
5153 }
5254 ) }
53- { ...( canLogTime && { onToggle : ( ) => primaryTimer . toggleTimer ( ) } ) }
55+ { ...( canLogTime && { onToggle : ( ) => timerApi . toggleTimer ( primaryTimer ) } ) }
5456 >
5557 < IssueTitle
5658 issue = { issue }
@@ -70,13 +72,13 @@ const Issue = ({ issue, localIssue, priorityType, assignedToMe, timers, onAddTim
7072 </ div >
7173 { canLogTime && ! areTimersExpanded && (
7274 < div >
73- < Timer . Root timer = { primaryTimer } issue = { issue } >
74- < Timer . Wrapper >
75- < Timer . Counter />
76- < Timer . ToggleButton />
77- < Timer . DoneButton canLogTime = { canLogTime } />
78- </ Timer . Wrapper >
79- </ Timer . Root >
75+ < TimerComponents . Root timer = { primaryTimer } issue = { issue } >
76+ < TimerComponents . Wrapper >
77+ < TimerComponents . Counter />
78+ < TimerComponents . ToggleButton />
79+ < TimerComponents . DoneButton canLogTime = { canLogTime } />
80+ </ TimerComponents . Wrapper >
81+ </ TimerComponents . Root >
8082 { timers . length > 1 && (
8183 < button type = "button" className = "text-muted-foreground pl-3 text-xs" onClick = { ( ) => setAreTimersExpanded ( true ) } >
8284 { formatMessage ( { id : "issues.timers.more-timers" } , { count : timers . length - 1 } ) }
@@ -88,16 +90,16 @@ const Issue = ({ issue, localIssue, priorityType, assignedToMe, timers, onAddTim
8890 { canLogTime && areTimersExpanded && (
8991 < div className = "mt-2 flex flex-col gap-y-1" >
9092 { timers . map ( ( timer ) => (
91- < Timer . Root key = { timer . id } timer = { timer } issue = { issue } >
92- < Timer . ContextMenu >
93- < Timer . WrapperCard >
94- < Timer . NameField />
95- < Timer . Counter />
96- < Timer . ToggleButton />
97- < Timer . DoneButton canLogTime = { canLogTime } />
98- </ Timer . WrapperCard >
99- </ Timer . ContextMenu >
100- </ Timer . Root >
93+ < TimerComponents . Root key = { timer . id } timer = { timer } issue = { issue } >
94+ < TimerComponents . ContextMenu >
95+ < TimerComponents . WrapperCard >
96+ < TimerComponents . NameField />
97+ < TimerComponents . Counter />
98+ < TimerComponents . ToggleButton />
99+ < TimerComponents . DoneButton canLogTime = { canLogTime } />
100+ </ TimerComponents . WrapperCard >
101+ </ TimerComponents . ContextMenu >
102+ </ TimerComponents . Root >
101103 ) ) }
102104 </ div >
103105 ) }
@@ -125,11 +127,11 @@ export const IssueSkeleton = () => (
125127 < div className = "mt-0.5" >
126128 < Skeleton className = "h-5.5 w-20 rounded-sm" />
127129 </ div >
128- < Timer . Wrapper >
129- < Timer . Skeleton . Counter />
130- < Timer . Skeleton . ToggleButton />
131- < Timer . Skeleton . DoneButton />
132- </ Timer . Wrapper >
130+ < TimerComponents . Wrapper >
131+ < TimerComponents . Skeleton . Counter />
132+ < TimerComponents . Skeleton . ToggleButton />
133+ < TimerComponents . Skeleton . DoneButton />
134+ </ TimerComponents . Wrapper >
133135 </ div >
134136 </ ToggleableCard >
135137) ;
0 commit comments