@@ -38,7 +38,7 @@ let votingStartTime = moment("3 May 2021 08:00:00 CDT");
3838let  votingEndTime  =  moment ( "7 May 2021 23:59:59 CDT" ) ; 
3939
4040// easy route testing by passing a date string below 
41- const  now  =  function ( )  { 
41+ const  getCurrentTime  =  function ( )  { 
4242 return  moment ( ) ; 
4343} ; 
4444
@@ -153,13 +153,15 @@ const routes = [
153153 path : "voting" , 
154154 name : "voting" , 
155155 component : ( )  =>  { 
156+  const  now  =  getCurrentTime ( ) ; 
157+ 
156158 // show VoteWoah if before vote start time 
157-  if  ( now ( )  <  votingStartTime )  { 
159+  if  ( now  <  votingStartTime )  { 
158160 return  import ( "@/views/Voting/VoteWoah" ) ; 
159161 } 
160162
161163 // show VotingOver if past vote end time 
162-  if  ( now ( )  >  votingEndTime )  { 
164+  if  ( now  >  votingEndTime )  { 
163165 // TODO: add a leaderboard here once built 
164166 return  import ( "@/views/Voting/VotingOver" ) ; 
165167 } 
@@ -180,17 +182,16 @@ const routes = [
180182 path : "quiz" , 
181183 name : "quiz" , 
182184 component : async  ( )  =>  { 
185+  const  now  =  getCurrentTime ( ) ; 
186+ 
183187 // time before challenge has started 
184-  if  ( now ( )  <  mainQuestionsStartTime )  { 
188+  if  ( now  <  mainQuestionsStartTime )  { 
185189 // TODO: update QuizCountdown's content for 2022's before start time 
186190 return  import ( "@/views/Quiz/QuizCountdown" ) ; 
187191 } 
188192
189193 // time during main quiz 
190-  if  ( 
191-  now ( )  >=  mainQuestionsStartTime  && 
192-  now ( )  <=  mainQuestionsEndTime 
193-  )  { 
194+  if  ( now  >=  mainQuestionsStartTime  &&  now  <=  mainQuestionsEndTime )  { 
194195 // USER HAS FINISHED QUIZ 
195196 // TODO: for 2022 import a 'you finished now wait for boss' component 
196197 // if done will all questions except boss 
@@ -200,15 +201,15 @@ const routes = [
200201 } 
201202
202203 // time between main questions ending and boss starting 
203-  if  ( now ( )  >  mainQuestionsEndTime  &&  now ( )  <  bossStartTime )  { 
204+  if  ( now  >  mainQuestionsEndTime  &&  now  <  bossStartTime )  { 
204205 // TODO: for 2022 make an await final boss component, or start passing props to QuizCountdown 
205206
206207 // MUST WAIT FOR NEXT QUESTION 
207208 return  import ( "@/views/Quiz/QuizCountdown" ) ; 
208209 } 
209210
210211 // time during boss final question 
211-  if  ( now ( )  >=  bossStartTime  &&  now ( )  <=  bossEndTime )  { 
212+  if  ( now  >=  bossStartTime  &&  now  <=  bossEndTime )  { 
212213 // User did not make the cut 
213214 if  ( 
214215 store . state . Quiz . rankToday  ==  store . state . Quiz . maxRank  && 
@@ -229,7 +230,7 @@ const routes = [
229230 } 
230231
231232 // time after boss question ends and before voting 
232-  if  ( now ( )  >  bossEndTime  &&  now ( )  <  votingStartTime )  { 
233+  if  ( now  >  bossEndTime  &&  now  <  votingStartTime )  { 
233234 // user has finished the boss question 
234235 if  ( store . state . Quiz . maxRank  ===  store . state . User . rank  -  1 )  { 
235236 return  import ( "@/views/Quiz/QuizFinished" ) ; 
@@ -243,8 +244,10 @@ const routes = [
243244 // TODO: make a component that alerts before redirect to /voting for better user experience 
244245 } , 
245246 beforeEnter ( from ,  to ,  next )  { 
247+  const  now  =  getCurrentTime ( ) ; 
248+ 
246249 // redirect if all sections of quiz are over 
247-  if  ( now ( )  >=  votingStartTime )  { 
250+  if  ( now  >=  votingStartTime )  { 
248251 next ( "/voting" ) ; 
249252 } 
250253
0 commit comments