@@ -102,8 +102,6 @@ function buildChartData(hoursData, totalHoursData) {
102102 ) ;
103103
104104 const userData = hoursByBucket . map ( range => {
105- // FALLBACK: If total hours is 0, visualizes chart layout by volunteer count
106- // so that the chart displays nicely instead of loading with empty 0 slices.
107105 const value = totalHoursWorked > 0 ? range . allocatedHours || 0 : range . count || 0 ;
108106 const denominator = totalHoursWorked > 0 ? totalAllocatedHours : totalVolunteers ;
109107
@@ -163,23 +161,25 @@ export default function VolunteerHoursDistribution({
163161 hoursData,
164162 totalHoursData,
165163} ) {
164+ // FIXED: Using standard globalThis setup
166165 const [ windowSize , setWindowSize ] = useState ( {
167- width : typeof window !== 'undefined' ? window . innerWidth : 1200 ,
168- height : typeof window !== 'undefined' ? window . innerHeight : 800 ,
166+ width : typeof globalThis . window !== 'undefined' ? globalThis . window . innerWidth : 1200 ,
167+ height : typeof globalThis . window !== 'undefined' ? globalThis . window . innerHeight : 800 ,
169168 } ) ;
170169
171170 useEffect ( ( ) => {
172- if ( typeof window === 'undefined' ) return ;
173-
174- const updateWindowSize = ( ) => {
175- setWindowSize ( {
176- width : window . innerWidth ,
177- height : window . innerHeight ,
178- } ) ;
179- } ;
180-
181- window . addEventListener ( 'resize' , updateWindowSize ) ;
182- return ( ) => window . removeEventListener ( 'resize' , updateWindowSize ) ;
171+ // FIXED: Cleaned up negated conditions and wrapped with explicit globalThis tracking
172+ if ( typeof globalThis . window !== 'undefined' ) {
173+ const updateWindowSize = ( ) => {
174+ setWindowSize ( {
175+ width : globalThis . window . innerWidth ,
176+ height : globalThis . window . innerHeight ,
177+ } ) ;
178+ } ;
179+
180+ globalThis . window . addEventListener ( 'resize' , updateWindowSize ) ;
181+ return ( ) => globalThis . window . removeEventListener ( 'resize' , updateWindowSize ) ;
182+ }
183183 } , [ ] ) ;
184184
185185 if ( isLoading ) {
@@ -221,4 +221,4 @@ export { HoursWorkList, mergeHoursBuckets };
221221export function computeDistribution ( hoursData , totalHoursData ) {
222222 const { userData, totalVolunteers, totalHoursWorked } = buildChartData ( hoursData , totalHoursData ) ;
223223 return { userData, totalVolunteers, totalHoursWorked } ;
224- }
224+ }
0 commit comments