@@ -77,21 +77,28 @@ const CountdownTimer = () => {
7777 const d = new Date ( ) ;
7878 const cur_time =
7979 d . getHours ( ) * 60 * 60 + d . getMinutes ( ) * 60 + d . getSeconds ( ) ;
80+ const cur_d = d . getDay ( ) ;
8081
8182 // filter out finished tasks
8283 upcomingTimes = ts . filter ( ( time ) => {
83- const end_time = serializeTime ( time . end_time ) ;
84- return end_time > cur_time ;
84+ return ! ( cur_d == time . day && serializeTime ( time . end_time ) <= cur_time ) ;
8585 } ) ;
8686
8787 // sort by start time
8888 upcomingTimes = upcomingTimes . sort ( ( a , b ) => {
89- return serializeTime ( a . start_time ) - serializeTime ( b . start_time ) ;
89+ return (
90+ serializeTime ( a . start_time ) +
91+ ( ( a . day + 8 - cur_d ) % 8 ) * 24 * 60 * 60 -
92+ ( serializeTime ( b . start_time ) + ( ( b . day + 8 - cur_d ) % 8 ) * 24 * 60 * 60 )
93+ ) ;
9094 } ) ;
9195
9296 // logic for if there are no tasks currently or at all
9397 if ( upcomingTimes . length > 0 ) {
94- if ( serializeTime ( upcomingTimes [ 0 ] . start_time ) < cur_time ) {
98+ if (
99+ serializeTime ( upcomingTimes [ 0 ] . start_time ) < cur_time &&
100+ upcomingTimes [ 0 ] . day == cur_d
101+ ) {
95102 setCurrentTime ( upcomingTimes [ 0 ] ) ;
96103 } else {
97104 setCurrentTime ( null ) ;
@@ -109,14 +116,6 @@ const CountdownTimer = () => {
109116 }
110117 }
111118
112- // check for tasks
113- // direct to make task page if no tasks
114- // refresh timer to check for tasks
115- // play timer if there is a current task
116-
117- // lonk in button
118- // lonk out
119-
120119 return (
121120 < div className = "h-screen bg-slate-800 p-8 font-inter" >
122121 < div className = "flex flex-col items-center justify-start rounded-xl bg-slate-700 p-8 font-mono text-white shadow-inner shadow-slate-900" >
@@ -125,23 +124,19 @@ const CountdownTimer = () => {
125124 < div className = "flex flex-col" >
126125 < div >
127126 { currentTime ? (
128- < div >
129- < TimeDisplay
130- statusSignal = { onTaskEnd }
131- time = { currentTime . end_time }
132- current = { true }
133- />
134- </ div >
127+ < TimeDisplay
128+ statusSignal = { onTaskEnd }
129+ time = { currentTime . end_time }
130+ current = { true }
131+ />
135132 ) : (
136133 < >
137134 { nextTime ? (
138- < div >
139- < TimeDisplay
140- statusSignal = { onTaskEnd }
141- time = { nextTime . start_time }
142- current = { false }
143- />
144- </ div >
135+ < TimeDisplay
136+ statusSignal = { onTaskEnd }
137+ time = { nextTime . start_time }
138+ current = { false }
139+ />
145140 ) : (
146141 < > </ >
147142 ) }
@@ -156,17 +151,17 @@ const CountdownTimer = () => {
156151 ) }
157152 </ div >
158153 </ div >
159- < div className = "justify-top flex flex-col pl-8" >
160- < div className = "p-4 font-inter text-xl font-semibold" > upcoming </ div >
161- < div >
162- { times . length > 0 ? (
163- < >
164- < UpcomingTasks tasks = { tasks } times = { times } / >
165- </ >
166- ) : (
167- < > </ >
168- ) }
169- </ div >
154+ < div >
155+ { times . length > 1 ? (
156+ < div className = "justify-top flex flex-col pl-8" >
157+ < div className = "p-4 font-inter text-2xl font-semibold" >
158+ upcoming
159+ </ div >
160+ < UpcomingTasks tasks = { tasks } times = { times } />
161+ </ div >
162+ ) : (
163+ < > </ >
164+ ) }
170165 </ div >
171166 </ div >
172167 < div className = "p-8" >
0 commit comments