Skip to content

Commit c3f3db5

Browse files
fixed api calling for people report
1 parent b9b8764 commit c3f3db5

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/components/Reports/TotalReport/TotalPeopleReport.jsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ function TotalPeopleReport(props) {
4545
return;
4646
}
4747

48+
// Don't make API call if userList is empty
49+
if (!userList || userList.length === 0) {
50+
// eslint-disable-next-line no-console
51+
console.warn('TotalPeopleReport: Skipping API call - userList is empty', {
52+
userProfilesLength: userProfiles?.length,
53+
userListLength: userList?.length,
54+
});
55+
setTotalPeopleReportDataLoading(false);
56+
setAllTimeEntries([]);
57+
return;
58+
}
59+
4860
try {
4961
// eslint-disable-next-line no-console
5062
console.log('TotalPeopleReport API Request:', {
@@ -226,14 +238,24 @@ function TotalPeopleReport(props) {
226238
}, [endDate, startDate, generateBarData, summaryOfTimeRange]);
227239

228240
useEffect(() => {
241+
// Only make API call if userList has data
242+
if (!userList || userList.length === 0) {
243+
// eslint-disable-next-line no-console
244+
console.log('TotalPeopleReport: Waiting for userProfiles to load...', {
245+
userProfilesLength: userProfiles?.length,
246+
userListLength: userList?.length,
247+
});
248+
return;
249+
}
250+
229251
setTotalPeopleReportDataReady(false);
230252
const controller = new AbortController();
231253
loadTimeEntriesForPeriod(controller).then(() => {
232254
setTotalPeopleReportDataLoading(false);
233255
setTotalPeopleReportDataReady(true);
234256
});
235257
return () => controller.abort();
236-
}, [loadTimeEntriesForPeriod, startDate, endDate]);
258+
}, [loadTimeEntriesForPeriod, startDate, endDate, userList]);
237259

238260
useEffect(() => {
239261
if (!totalPeopleReportDataLoading && totalPeopleReportDataReady) {

0 commit comments

Comments
 (0)