Enhance authentication flow by adding return URL support
This commit updates the authentication process to include a return URL parameter, allowing users to be redirected back to their original page after logging in. Changes were made to the AuthController, Login component, and Routes component to handle the return URL appropriately. Additionally, improvements were made to the TeamScheduler and TeamSchedulerSolution classes for better team and student management. These enhancements improve user experience and navigation within the application.
This commit is contained in:
@@ -172,7 +172,18 @@
|
||||
_isLoading = true;
|
||||
try
|
||||
{
|
||||
// Load all students with their teams
|
||||
// Load teams with their students separately to avoid circular reference
|
||||
var teamsWithStudents = await Context.Teams
|
||||
.AsNoTracking()
|
||||
.Include(t => t.Students)
|
||||
.Include(t => t.Event)
|
||||
.Include(t => t.Captain)
|
||||
.ToListAsync();
|
||||
|
||||
// Create a dictionary for quick lookup of team students
|
||||
var teamStudentsDict = teamsWithStudents.ToDictionary(t => t.Id, t => t.Students.ToList());
|
||||
|
||||
// Load all students with their teams (without loading team students to avoid circular reference)
|
||||
var students = await Context.Students
|
||||
.AsNoTracking()
|
||||
.Include(s => s.Teams)
|
||||
@@ -181,6 +192,18 @@
|
||||
.ThenInclude(t => t.Captain)
|
||||
.ToListAsync();
|
||||
|
||||
// Populate Students for each team from the separately loaded teams
|
||||
foreach (var student in students)
|
||||
{
|
||||
foreach (var team in student.Teams)
|
||||
{
|
||||
if (teamStudentsDict.TryGetValue(team.Id, out var teamStudents))
|
||||
{
|
||||
team.Students = teamStudents;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Filter to only students with teams
|
||||
var studentTeams = students
|
||||
.Where(s => s.Teams.Any(t => t?.Event != null && (!_showRegionalOnly || t.Event.RegionalEvent)))
|
||||
|
||||
Reference in New Issue
Block a user