diff --git a/src/app.py b/src/app.py index 4ebb1d9..f1f607b 100644 --- a/src/app.py +++ b/src/app.py @@ -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": "Tuesdays and Thursdays, 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": "Wednesdays, 3:30 PM - 5:00 PM", + "max_participants": 15, + "participants": ["liam@mergington.edu", "ava@mergington.edu"] + }, + # Artistic activities + "Art Club": { + "description": "Explore painting, drawing, and other visual arts", + "schedule": "Mondays, 3:30 PM - 5:00 PM", + "max_participants": 16, + "participants": ["noah@mergington.edu", "isabella@mergington.edu"] + }, + "Drama Society": { + "description": "Participate in school plays and drama workshops", + "schedule": "Fridays, 4:00 PM - 5:30 PM", + "max_participants": 20, + "participants": ["charlotte@mergington.edu", "jack@mergington.edu"] + }, + # Intellectual activities + "Math Olympiad": { + "description": "Prepare for math competitions and solve challenging problems", + "schedule": "Thursdays, 3:30 PM - 5:00 PM", + "max_participants": 10, + "participants": ["amelia@mergington.edu", "benjamin@mergington.edu"] + }, + "Science Club": { + "description": "Conduct experiments and explore scientific concepts", + "schedule": "Wednesdays, 4:00 PM - 5:00 PM", + "max_participants": 14, + "participants": ["elijah@mergington.edu", "harper@mergington.edu"] } } @@ -55,6 +94,11 @@ def get_activities(): @app.post("/activities/{activity_name}/signup") def signup_for_activity(activity_name: str, email: str): """Sign up a student for an activity""" + # Validate student is not already signed up + for activity in activities.values(): + if email in activity["participants"]: + raise HTTPException(status_code=400, detail="Student already signed up for an activity") + # Validate activity exists if activity_name not in activities: raise HTTPException(status_code=404, detail="Activity not found") diff --git a/src/static/app.js b/src/static/app.js index dcc1e38..8216dcd 100644 --- a/src/static/app.js +++ b/src/static/app.js @@ -20,11 +20,31 @@ document.addEventListener("DOMContentLoaded", () => { const spotsLeft = details.max_participants - details.participants.length; + // Participants section + let participantsHTML = ""; + if (details.participants.length > 0) { + participantsHTML = ` +
${details.description}
Schedule: ${details.schedule}
Availability: ${spotsLeft} spots left
+ ${participantsHTML} `; activitiesList.appendChild(activityCard); diff --git a/src/static/styles.css b/src/static/styles.css index a533b32..8de918e 100644 --- a/src/static/styles.css +++ b/src/static/styles.css @@ -142,3 +142,29 @@ footer { padding: 20px; color: #666; } + +.participants-section { + margin-top: 12px; + padding: 10px; + background-color: #e3eafc; + border-radius: 4px; +} + +.participants-section strong { + color: #1a237e; +} + +.participants-list { + margin: 8px 0 0 18px; + padding-left: 0; + list-style-type: disc; + color: #333; + font-size: 15px; +} + +.no-participants { + background-color: #f9fbe7; + color: #757575; + font-style: italic; + border: 1px dashed #cfd8dc; +}