The trainee availability system manages which trainees can be selected for sessions in specific time slots. This document explains the key data structures and workflows that handle trainee availability.
dailyHourToSessions = {
"05/01/2024": { // Date
"10:00": [ // Hour
{ id: 1, traineeId: "A1", ...}, // Saved sessions
{ id: 2, traineeId: "B1", ...}
],
"11:00": [ ... ]
}
}
This is the source of truth for all saved sessions, organized by date and hour.
getTraineesForHour("10:00") {
1. Gets existing sessions from dailyHourToSessions["05/01/2024"]["10:00"]
2. Gets new sessions from newSessionsSummary
3. Combines and returns all trainees for that hour
Returns: [Alice, Bob] // All trainees in that hour slot
}
This function combines both saved and new (unsaved) sessions to determine which trainees are scheduled for a specific hour.
sameHourPeople = [
// Result of getTraineesForHour()
// Used by TraineeDropdown to filter out unavailable trainees
{id: "A1", firstName: "Alice", ...},
{id: "B1", firstName: "Bob", ...}
]
This array contains all trainees who are currently scheduled for a specific hour, used to determine who should be unavailable in the dropdown.
dailyHourToSessions["05/01/2024"]["10:00"] = [
{id: 1, traineeId: "A1", trainee: Alice}, // Saved session
{id: 2, traineeId: "B1", trainee: Bob} // Saved session
]
newSessionsSummary = [
{tempId: "temp1", traineeId: "C1", trainee: Charlie} // New unsaved session
]
getTraineesForHour("10:00") => [Alice, Bob, Charlie]
sameHourPeople = [Alice, Bob, Charlie]
availableTrainees = [David, Eve] // Filtered by TraineeDropdown
When Alice's session is removed:
removeSession(session1)
is calleddailyHourToSessions
is updated to remove Alice's sessiongetTraineesForHour("10:00")
recalculates, now returning[Bob, Charlie]
sameHourPeople
is updated to[Bob, Charlie]
- TraineeDropdown recalculates
availableTrainees
, now showing[Alice, David, Eve]
dailyHourToSessions
maintains the source of truth for saved sessionsgetTraineesForHour
combines both saved and new sessionssameHourPeople
is used by TraineeDropdown to filter available trainees- Removing a session triggers a chain reaction that makes the trainee available again
- The system automatically updates all dropdowns when changes occur
- Previous: Refactoring Journey
- Next: Data Structures
- Back to Home