Skip to content

Commit f1dac23

Browse files
Update activity attendance UI and styles
1 parent 33ef443 commit f1dac23

2 files changed

Lines changed: 144 additions & 36 deletions

File tree

src/components/CommunityPortal/Activities/ActivityAttendance.jsx

Lines changed: 88 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,35 @@ import profileImg from '../../../assets/images/profile.png';
99

1010
ChartJS.register(ArcElement, Tooltip, Legend);
1111

12-
function StatsChart({ stats }) {
13-
const totalMembers = stats.find(stat => stat.title === 'Total Community Members')?.value || 1;
14-
const registered = stats.find(stat => stat.title === 'Registered')?.value || 0;
15-
const percentage = ((registered / totalMembers) * 100).toFixed(1);
12+
function deriveAttendanceMetrics({
13+
totalCommunityMembers,
14+
registeredMembers,
15+
registeredNoShows,
16+
communityVisitors,
17+
}) {
18+
const attendingMembers = Math.max(registeredMembers - registeredNoShows, 0);
1619

20+
const totalAttendees = attendingMembers + communityVisitors;
21+
22+
const participationPercentage =
23+
totalCommunityMembers > 0
24+
? Number(((totalAttendees / totalCommunityMembers) * 100).toFixed(1))
25+
: 0;
26+
27+
return {
28+
attendingMembers,
29+
totalAttendees,
30+
participationPercentage,
31+
};
32+
}
33+
34+
function StatsChart({ attendingMembers, communityVisitors, participationPercentage }) {
1735
const data = {
18-
labels: stats.map(stat => stat.title),
36+
labels: ['Attending Members', 'Community Visitors'],
1937
datasets: [
2038
{
21-
data: stats.map(stat => stat.value),
22-
backgroundColor: ['#4CAF50', '#2196F3', '#F44336', '#FF9800'],
23-
hoverBackgroundColor: ['#388E3C', '#1976D2', '#D32F2F', '#F57C00'],
39+
data: [attendingMembers, communityVisitors],
40+
backgroundColor: ['#2196F3', '#FF9800'],
2441
borderWidth: 1,
2542
},
2643
],
@@ -30,14 +47,23 @@ function StatsChart({ stats }) {
3047
cutout: '70%',
3148
plugins: {
3249
legend: { display: false },
33-
tooltip: { enabled: true },
50+
tooltip: {
51+
callbacks: {
52+
label: ctx => {
53+
const total = attendingMembers + communityVisitors;
54+
const value = ctx.raw;
55+
const percent = total > 0 ? ((value / total) * 100).toFixed(1) : 0;
56+
return `${ctx.label}: ${value} (${percent}%)`;
57+
},
58+
},
59+
},
3460
},
3561
};
3662

3763
return (
3864
<div className={styles.chartContainer}>
3965
<Doughnut data={data} options={options} />
40-
<div className={styles.chartLabel}>{percentage}%</div>
66+
<div className={styles.chartLabel}>{participationPercentage}%</div>
4167
</div>
4268
);
4369
}
@@ -57,7 +83,7 @@ const exportToCSV = students => {
5783
document.body.removeChild(link);
5884
};
5985

60-
function StatsCard({ title, value, color, definition }) {
86+
function StatsCard({ title, value, colorClass, definition }) {
6187
return (
6288
<div className={styles.statsCard}>
6389
<div className={styles.statsCardHeader}>
@@ -71,9 +97,7 @@ function StatsCard({ title, value, color, definition }) {
7197
<FaInfoCircle className={styles.infoIcon} />
7298
</button>
7399
</div>
74-
<p className={styles.statsValue} style={{ color }}>
75-
{value}
76-
</p>
100+
<p className={`${styles.statsValue} ${styles[colorClass]}`}>{value}</p>
77101
</div>
78102
);
79103
}
@@ -168,34 +192,62 @@ function ActivityAttendance() {
168192
const [searchTerm, setSearchTerm] = useState('');
169193
const [statusFilter, setStatusFilter] = useState('All');
170194

195+
/* -------- Raw inputs -------- */
196+
const totalCommunityMembers = 400;
197+
const registeredMembers = 100;
198+
const registeredNoShows = 15;
199+
const communityVisitors = 19;
200+
201+
const { attendingMembers, totalAttendees, participationPercentage } = deriveAttendanceMetrics({
202+
totalCommunityMembers,
203+
registeredMembers,
204+
registeredNoShows,
205+
communityVisitors,
206+
});
207+
171208
const statsData = [
172209
{
173210
id: uuidv4(),
174211
title: 'Total Community Members',
175-
value: 400,
176-
color: '#4CAF50',
177-
definition: 'All members registered in the community, including inactive users and visitors.',
212+
value: totalCommunityMembers,
213+
colorClass: 'statGreen',
214+
definition: 'Total number of people who live in the community.',
178215
},
179216
{
180217
id: uuidv4(),
181-
title: 'Registered',
182-
value: 100,
183-
color: '#2196F3',
184-
definition: 'Members registered for the selected event/session only.',
218+
title: 'Registered Members',
219+
value: registeredMembers,
220+
colorClass: 'statBlue',
221+
definition: 'Community members who registered for the event/session.',
185222
},
186223
{
187224
id: uuidv4(),
188-
title: 'No Show',
189-
value: 15,
190-
color: '#F44336',
191-
definition: 'Registered members who did not check in or attend the event.',
225+
title: 'Registered No-Shows',
226+
value: registeredNoShows,
227+
colorClass: 'statRed',
228+
definition: 'Registered community members who did not attend the event.',
192229
},
193230
{
194231
id: uuidv4(),
195-
title: 'Community Visitor',
196-
value: 19,
197-
color: '#FF9800',
198-
definition: 'Non-registered participants who attended the event.',
232+
title: 'Attending Members',
233+
value: attendingMembers,
234+
colorClass: 'statBlue',
235+
definition: 'Community members who registered and actually attended the event.',
236+
},
237+
{
238+
id: uuidv4(),
239+
title: 'Community Visitors',
240+
value: communityVisitors,
241+
colorClass: 'statOrange',
242+
definition: 'Non-community members who attended the event.',
243+
},
244+
{
245+
id: uuidv4(),
246+
title: 'Total Attendees',
247+
value: totalAttendees,
248+
colorClass: 'statDarkGreen',
249+
definition:
250+
'Total number of people who attended the event. Used for participation and continuation decisions.',
199251
},
200252
];
201253

@@ -232,21 +284,25 @@ function ActivityAttendance() {
232284

233285
<div className={styles.dashboardMain}>
234286
<div className={styles.statsChartContainer}>
235-
<StatsChart stats={statsData} />
287+
<StatsChart
288+
attendingMembers={attendingMembers}
289+
communityVisitors={communityVisitors}
290+
participationPercentage={participationPercentage}
291+
/>
292+
236293
<div className={styles.statsGrid}>
237294
{statsData.map(stat => (
238295
<StatsCard
239296
key={stat.id}
240297
title={stat.title}
241298
value={stat.value}
242-
color={stat.color}
299+
colorClass={stat.colorClass}
243300
definition={stat.definition}
244301
/>
245302
))}
246303
</div>
247304
</div>
248305

249-
{/* Live Student Updates */}
250306
<LiveUpdates
251307
students={students}
252308
searchTerm={searchTerm}

src/components/CommunityPortal/Activities/ActivityAttendance.module.css

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,32 @@
1313
min-height: 100vh;
1414
background-color: var(--bg-color);
1515
color: var(--text-color);
16+
17+
--stat-green: #4caf50;
18+
--stat-blue: #2196f3;
19+
--stat-red: #f44336;
20+
--stat-orange: #ff9800;
21+
--stat-dark-green: #2e7d32;
22+
}
23+
24+
.statGreen {
25+
color: var(--stat-green);
26+
}
27+
28+
.statBlue {
29+
color: var(--stat-blue);
30+
}
31+
32+
.statRed {
33+
color: var(--stat-red);
34+
}
35+
36+
.statOrange {
37+
color: var(--stat-orange);
38+
}
39+
40+
.statDarkGreen {
41+
color: var(--stat-dark-green);
1642
}
1743

1844
/* ======================================
@@ -27,6 +53,32 @@
2753
--border-color: #3b4a66;
2854
--shadow-color: rgba(255, 255, 255, 0.1);
2955
--card-shadow: rgba(255, 255, 255, 0.1);
56+
57+
--stat-green: #4caf50;
58+
--stat-blue: #2196f3;
59+
--stat-red: #f44336;
60+
--stat-orange: #ff9800;
61+
--stat-dark-green: #81c784;
62+
}
63+
64+
.activityAttendanceDarkMode .statBlue {
65+
color: var(--stat-blue) !important;
66+
}
67+
68+
.activityAttendanceDarkMode .statGreen {
69+
color: var(--stat-green) !important;
70+
}
71+
72+
.activityAttendanceDarkMode .statRed {
73+
color: var(--stat-red) !important;
74+
}
75+
76+
.activityAttendanceDarkMode .statOrange {
77+
color: var(--stat-orange) !important;
78+
}
79+
80+
.activityAttendanceDarkMode .statDarkGreen {
81+
color: var(--stat-dark-green) !important;
3082
}
3183

3284
/* Apply shadow on images if you have any .activity-agenda-image */
@@ -142,9 +194,9 @@
142194

143195
.chartContainer {
144196
position: relative;
145-
width: 180px;
146-
height: 180px;
147-
flex: 0 0 180px; /* never shrink below 180px */
197+
width: 190px;
198+
height: 190px;
199+
flex: 0 0 190px; /* never shrink below 190px */
148200
margin: 0 auto;
149201
}
150202

@@ -215,7 +267,7 @@
215267
transition: color 0.2s ease;
216268
}
217269

218-
.infoIconWrapper:hover,
270+
.infoIconWrapper:hover,
219271
.infoIconWrapper:focus {
220272
color: var(--heading-color);
221273
outline: none;

0 commit comments

Comments
 (0)