TEST
// Example JSON response
const jsonResponse = {
“request_uri”: “/api/v1/groupex/41/class-date/today”,
“data”: {
“date”: “2023-01-17”,
“classId”: 41,
“className”: “Cardio Funk/ Toning – monthly”,
“startTime”: “10:00:00”,
“endTime”: “10:18:00”,
“description”: “This is a fun aerobics class that will get you moving to the latest dance moves and music, including weights to sculpt your muscle.”,
“maxAvailableSpots”: 5,
“department”: “Cardio Funk/ Toning”,
“locationName”: “Team Headquarters”,
“resource”: “reclique side”,
“instructors”: [
{
“id”: 9,
“name”: “April Brown”
}
],
“classStatus”: “ACTIVE”,
“category”: 12,
“level”: “Intermediate”,
“waitlist”: “Unavailable”,
“currentlyRegistered”: 0,
“Intensity”: 0,
“BranchID”: 44,
“RequiresRegistration”: true,
“RegistrationLink”: “https://metropolis.recliquecore.com/programs/register/c/41/date/2023-01-17”,
“currentAvailableSpots”: 5
},
“status”: “success”
};
// Function to format class details
function formatClassDetails(data) {
return `
Class Details:
- Class Name: ${data.className}
- Date: ${new Date(data.date).toDateString()}
- Time: ${data.startTime} – ${data.endTime}
- Description: ${data.description}
- Department: ${data.department}
- Location: ${data.locationName}
- Instructor(s): ${data.instructors.map(instructor => instructor.name).join(‘, ‘)}
- Status: ${data.classStatus}
- Level: ${data.level}
- Max Available Spots: ${data.maxAvailableSpots}
- Currently Registered: ${data.currentlyRegistered}
- Waitlist: ${data.waitlist}
- Registration Required: ${data.RequiresRegistration ? ‘Yes’ : ‘No’}
- Registration Link: Register Here
`;
}
// Get the element where class details will be displayed
const classDetailsContainer = document.getElementById(‘class-details’);
// Format and display class details
classDetailsContainer.innerHTML = formatClassDetails(jsonResponse.data);