11import React , { useEffect , useState } from 'react' ;
2+ import { clsx } from 'clsx' ;
23import { useStore } from '@/store/useStore' ;
34import { getStatusInfo } from '@/services/scheduleService' ;
45import { HeroCard } from '@/components/home/HeroCard' ;
@@ -28,19 +29,29 @@ export const Home: React.FC = () => {
2829 return ( ) => clearInterval ( timer ) ;
2930 } , [ ] ) ;
3031
31- // REAL TIME STATUS (Always facts for now)
32- const currentHour = realTime . getHours ( ) ;
33- const isOn = currentQueuesStr [ currentHour ] === '1' ;
34-
35- let nextChangeHour = 24 ;
36- for ( let i = currentHour + 1 ; i < 24 ; i ++ ) {
37- if ( currentQueuesStr [ i ] !== ( isOn ? '1' : '0' ) ) {
38- nextChangeHour = i ;
39- break ;
32+ // CENTRALIZED DISPLAY CONTEXT (The 'Time Machine' Hub)
33+ const displayContext = React . useMemo ( ( ) => {
34+ // Determine the reference time (Real or Virtual)
35+ let referenceDate = new Date ( realTime ) ;
36+
37+ if ( scrubSlot !== null ) {
38+ // Set to virtual time (slot 0 = 00:00, slot 1 = 00:30, etc.)
39+ const vHour = Math . floor ( scrubSlot / 2 ) ;
40+ const vMin = ( scrubSlot % 2 ) * 30 ;
41+ referenceDate . setHours ( vHour , vMin , 0 , 0 ) ;
4042 }
41- }
4243
43- const { h : timeH , m : timeM } = getStatusInfo ( currentQueuesStr ) ;
44+ const info = getStatusInfo ( currentQueuesStr , referenceDate ) ;
45+
46+ return {
47+ referenceDate,
48+ isVirtual : scrubSlot !== null ,
49+ isOn : info . isCurrentlyOn ,
50+ timeH : info . h ,
51+ timeM : info . m ,
52+ nextChangeHour : info . nextChangeHour
53+ } ;
54+ } , [ realTime , scrubSlot , currentQueuesStr ] ) ;
4455
4556 // VIRTUAL POINTER PERCENT
4657 // Use SLOTS_COUNT - 1 (47) to perfectly align 100% with the right edge
@@ -49,21 +60,21 @@ export const Home: React.FC = () => {
4960 : ( ( realTime . getHours ( ) * 60 + realTime . getMinutes ( ) ) / 1440 ) * 100 ;
5061
5162 return (
52- < div className = "page-home" >
63+ < div className = { clsx ( "page-home" , ! displayContext . isOn && "status-off" ) } >
5364 < section id = "home-section" className = "animate-in fade-in duration-700" >
54- < div style = { { height : '16px' } } />
55-
56-
5765 < HeroCard
58- isOn = { isOn }
59- timeH = { timeH }
60- timeM = { timeM }
61- nextChangeHour = { nextChangeHour }
66+ isOn = { displayContext . isOn }
67+ timeH = { displayContext . timeH }
68+ timeM = { displayContext . timeM }
69+ nextChangeHour = { displayContext . nextChangeHour }
6270 queuesStr = { currentQueuesStr }
6371 currentTimePercent = { pointerPercent }
6472 />
6573
66- < DashboardBar isOn = { isOn } realTime = { realTime } />
74+ < DashboardBar
75+ isOn = { displayContext . isOn }
76+ realTime = { displayContext . referenceDate }
77+ />
6778
6879 < InteractiveTimeline
6980 queuesStr = { currentQueuesStr }
@@ -74,9 +85,6 @@ export const Home: React.FC = () => {
7485 selectedGroup = { selectedGroup }
7586 onSelect = { setSelectedGroup }
7687 />
77-
78- { /* Spacer for bottom nav */ }
79- < div style = { { height : '100px' } } />
8088 </ section >
8189 </ div >
8290 ) ;
0 commit comments