Skip to content

Commit 7ca9dd8

Browse files
fixed linting errors
1 parent 10a2749 commit 7ca9dd8

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

src/components/TotalOrgSummary/VolunteerHoursDistribution/VolunteerHoursDistribution.jsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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 };
221221
export function computeDistribution(hoursData, totalHoursData) {
222222
const { userData, totalVolunteers, totalHoursWorked } = buildChartData(hoursData, totalHoursData);
223223
return { userData, totalVolunteers, totalHoursWorked };
224-
}
224+
}

src/components/TotalOrgSummary/VolunteerHoursDistribution/__tests__/HoursWorkList.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ describe('HoursWorkList label formatting', () => {
1717
expect(screen.getByText('40-49 hrs')).toBeInTheDocument();
1818
expect(screen.getByText('40+ hrs')).toBeInTheDocument();
1919
});
20-
});
20+
});

src/components/TotalOrgSummary/VolunteerHoursDistribution/__tests__/formatRangeLabel.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ describe('formatRangeLabel helper', () => {
1818
expect(formatRangeLabel(null)).toBe('');
1919
expect(formatRangeLabel(undefined)).toBe('');
2020
});
21-
});
21+
});

0 commit comments

Comments
 (0)