diff --git a/pages/cart/publishers/stats.tsx b/pages/cart/publishers/stats.tsx index f3af7ef..813a40b 100644 --- a/pages/cart/publishers/stats.tsx +++ b/pages/cart/publishers/stats.tsx @@ -84,7 +84,7 @@ function ContactsPage({ allPublishers }) { } useEffect(() => { - let filtered = allPublishers.filter(publisher => + let filtered = publishers.filter(publisher => (publisher.firstName.toLowerCase().includes(searchQuery.toLowerCase()) || publisher.lastName.toLowerCase().includes(searchQuery.toLowerCase()) || publisher.email.toLowerCase().includes(searchQuery.toLowerCase()) || @@ -116,7 +116,7 @@ function ContactsPage({ allPublishers }) { } setFilteredPublishers(filtered); setPubWithAssignmentsCount(filtered.filter(publisher => publisher.currentMonthAvailabilityHoursCount && publisher.currentMonthAvailabilityHoursCount > 0).length); - }, [searchQuery, publisherType, sortField, sortOrder, allPublishers, hideEmptyFields]); + }, [searchQuery, publisherType, sortField, sortOrder, allPublishers, hideEmptyFields, selectedMonth]); useEffect(() => { if (isMounted.current) { @@ -127,8 +127,8 @@ function ContactsPage({ allPublishers }) { const response = await axiosInstance.get(`/api/?action=getAllPublishersWithStatistics&date=${filterDate.toISOString()}&noEndDate=false`); setPublishers(response.data); setFilteredPublishers(response.data); - setPubWithAssignmentsCount(response.data.filter(publisher => publisher.currentMonthAvailabilityHoursCount && publisher.currentMonthAvailabilityHoursCount > 0).length); + setHideEmptyFields({ availability: 'off', assignments: 'off', lastLogin: false, notifiications: false }) } catch (error) { console.error('Failed to fetch publishers data:', error); // Optionally, handle errors more gracefully here