Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add events with 0 attendance stats and fix search button #401

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/screens/Events/EventsSummary/OverallAttendanceSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ const OverallAttendanceSummary = () => {
const [computedStats, setComputedStats] = useState([]);

useEffect(() => {
onRefresh();
computeStats();
}, [startDate, endDate]);

const onRefresh = async () => {
const computeStats = async () => {
// grab the events
setLoading(true);

await getEvents(user.organizationId)
await getEvents(user.organizationId, startDate, endDate)
.then((result) => {
console.log(result);
if (result?.data?.events) {
setEvents(result.data.events);
}
Expand Down Expand Up @@ -64,6 +65,22 @@ const OverallAttendanceSummary = () => {
});
}
});
if (computedStats.length !== events.length) {
events.forEach((event) => {
let eventStats = computedStats.filter((stat) => stat._id === event._id);
if (!eventStats.length) {
computedStats.push({
_id: event._id,
title: event.eventParent.title,
date: event.date,
startTime: event.eventParent.startTime,
endTime: event.eventParent.endTime,
attendance: 0,
hours: 0,
});
}
});
}
setAttend(volunteers);
setHours(Math.round((mins / 60) * 100) / 100);
setComputedStats(computedStats);
Expand Down Expand Up @@ -91,6 +108,7 @@ const OverallAttendanceSummary = () => {
end.setMinutes(end.getMinutes() - offset);
setEndDate(end);
}
computeStats();
};

return (
Expand Down