Skip to content
Merged
Show file tree
Hide file tree
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
42 changes: 42 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,45 @@
"schedule": "Mondays, Wednesdays, Fridays, 2:00 PM - 3:00 PM",
"max_participants": 30,
"participants": ["john@mergington.edu", "olivia@mergington.edu"]
},
# Sports related activities
"Soccer Team": {
"description": "Join the school soccer team and compete in local leagues",
"schedule": "Wednesdays and Fridays, 4:00 PM - 5:30 PM",
"max_participants": 18,
"participants": ["lucas@mergington.edu", "mia@mergington.edu"]
},
"Basketball Club": {
"description": "Practice basketball skills and play friendly matches",
"schedule": "Tuesdays, 5:00 PM - 6:30 PM",
"max_participants": 15,
"participants": ["liam@mergington.edu", "ava@mergington.edu"]
},
# Artistic activities
"Art Club": {
"description": "Explore painting, drawing, and other visual arts",
"schedule": "Thursdays, 3:30 PM - 5:00 PM",
"max_participants": 16,
"participants": ["grace@mergington.edu", "noah@mergington.edu"]
},
"Drama Society": {
"description": "Participate in acting, stage production, and theater games",
"schedule": "Mondays, 4:00 PM - 5:30 PM",
"max_participants": 20,
"participants": ["ella@mergington.edu", "jack@mergington.edu"]
},
# Intellectual activities
"Math Olympiad": {
"description": "Prepare for math competitions and solve challenging problems",
"schedule": "Wednesdays, 3:30 PM - 5:00 PM",
"max_participants": 10,
"participants": ["ethan@mergington.edu", "isabella@mergington.edu"]
},
"Science Club": {
"description": "Conduct experiments and explore scientific concepts",
"schedule": "Fridays, 2:00 PM - 3:30 PM",
"max_participants": 14,
"participants": ["benjamin@mergington.edu", "charlotte@mergington.edu"]
}
}

Expand All @@ -62,6 +101,9 @@ def signup_for_activity(activity_name: str, email: str):
# Get the specific activity
activity = activities[activity_name]

# Validate student is not already signed up
if email in activity["participants"]:
raise HTTPException(status_code=400, detail="Student already signed up")
# Add student
activity["participants"].append(email)
return {"message": f"Signed up {email} for {activity_name}"}
21 changes: 21 additions & 0 deletions src/static/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,32 @@ document.addEventListener("DOMContentLoaded", () => {

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

// Build participants list HTML
let participantsHTML = "";
if (details.participants.length > 0) {
participantsHTML = `
<ul class="participants-list">
${details.participants
.map(
(p) =>
`<li><span class="participant-icon">👤</span> ${p.name || p.email || p}</li>`
)
.join("")}
</ul>
`;
} else {
participantsHTML = `<div class="no-participants">No participants yet.</div>`;
}

activityCard.innerHTML = `
<h4>${name}</h4>
<p>${details.description}</p>
<p><strong>Schedule:</strong> ${details.schedule}</p>
<p><strong>Availability:</strong> ${spotsLeft} spots left</p>
<div class="participants-section">
<div class="participants-title">Participants</div>
${participantsHTML}
</div>
`;

activitiesList.appendChild(activityCard);
Expand Down
43 changes: 43 additions & 0 deletions src/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ section h3 {
border: 1px solid #ddd;
border-radius: 5px;
background-color: #f9f9f9;
position: relative;
}

.activity-card h4 {
Expand Down Expand Up @@ -142,3 +143,45 @@ footer {
padding: 20px;
color: #666;
}

.participants-section {
margin-top: 18px;
padding: 12px 14px;
background: #eef3fa;
border-radius: 7px;
border: 1px solid #dde6f3;
}

.participants-title {
font-weight: 600;
color: #1a237e;
margin-bottom: 8px;
font-size: 1.05em;
letter-spacing: 0.5px;
}

.participants-list {
list-style: none;
padding-left: 0;
margin: 0;
}

.participants-list li {
margin-bottom: 6px;
padding-left: 0;
color: #333;
display: flex;
align-items: center;
font-size: 0.98em;
}

.participant-icon {
margin-right: 7px;
font-size: 1.1em;
}

.no-participants {
color: #888;
font-style: italic;
font-size: 0.97em;
}