Skip to content

Commit a9ea978

Browse files
committed
Add participants list and styling to activity cards
1 parent 54b4825 commit a9ea978

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/static/app.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,22 @@ document.addEventListener("DOMContentLoaded", () => {
2020

2121
const spotsLeft = details.max_participants - details.participants.length;
2222

23+
// Create participants list
24+
const participantsList = details.participants.length
25+
? `<ul class="participants-list">
26+
${details.participants.map((participant) => `<li>${participant}</li>`).join("")}
27+
</ul>`
28+
: "<p class='no-participants'>No participants yet.</p>";
29+
2330
activityCard.innerHTML = `
2431
<h4>${name}</h4>
2532
<p>${details.description}</p>
2633
<p><strong>Schedule:</strong> ${details.schedule}</p>
2734
<p><strong>Availability:</strong> ${spotsLeft} spots left</p>
35+
<div class="participants-section">
36+
<h5>Participants:</h5>
37+
${participantsList}
38+
</div>
2839
`;
2940

3041
activitiesList.appendChild(activityCard);
@@ -62,6 +73,7 @@ document.addEventListener("DOMContentLoaded", () => {
6273
messageDiv.textContent = result.message;
6374
messageDiv.className = "success";
6475
signupForm.reset();
76+
fetchActivities(); // Refresh activities list
6577
} else {
6678
messageDiv.textContent = result.detail || "An error occurred";
6779
messageDiv.className = "error";
@@ -83,4 +95,4 @@ document.addEventListener("DOMContentLoaded", () => {
8395

8496
// Initialize app
8597
fetchActivities();
86-
});
98+
});

src/static/styles.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,26 @@ footer {
142142
padding: 20px;
143143
color: #666;
144144
}
145+
.participants-section {
146+
margin-top: 15px;
147+
padding: 10px;
148+
background-color: #f1f8e9;
149+
border: 1px solid #c5e1a5;
150+
border-radius: 5px;
151+
}
152+
153+
.participants-section h5 {
154+
margin-bottom: 10px;
155+
color: #2e7d32;
156+
}
157+
158+
.participants-list {
159+
list-style-type: disc;
160+
padding-left: 20px;
161+
color: #333;
162+
}
163+
164+
.no-participants {
165+
color: #757575;
166+
font-style: italic;
167+
}

0 commit comments

Comments
 (0)