From 432caa0fe822d8a3a306bfc971bd9e3d980a7672 Mon Sep 17 00:00:00 2001 From: James Kolpack Date: Wed, 8 Apr 2026 22:11:31 -0400 Subject: [PATCH] Refactor StateScheduleHandout component to improve event occurrence filtering and display --- .../Calendar/StateScheduleHandout.razor | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/WebApp/Components/Features/Calendar/StateScheduleHandout.razor b/WebApp/Components/Features/Calendar/StateScheduleHandout.razor index a533b93..77c8e56 100644 --- a/WebApp/Components/Features/Calendar/StateScheduleHandout.razor +++ b/WebApp/Components/Features/Calendar/StateScheduleHandout.razor @@ -106,12 +106,15 @@ else Combined schedule - All imported occurrences for this chapter database. - @if (_allOccurrences.Count == 0) - { - No event occurrences in the database. Import a schedule from the calendar first. + Imported occurrences relevant to this chapter. + @{ + var combinedOccurrences = GetCombinedScheduleOccurrences().ToList(); } - @foreach (var dateGroup in _allOccurrences.GroupBy(o => o.StartTime.Date)) + @if (combinedOccurrences.Count == 0) + { + No relevant event occurrences found for your current team registrations. + } + @foreach (var dateGroup in combinedOccurrences.GroupBy(o => o.StartTime.Date)) { @FormatDateHeading(dateGroup.Key) @@ -242,6 +245,21 @@ else .DistinctBy(o => (o.StartTime, o.Name ?? "")); } + private IEnumerable GetCombinedScheduleOccurrences() + { + return _allOccurrences! + .Where(o => + { + // Keep chapter-wide/special schedule rows. + if (!o.EventDefinitionId.HasValue) + return true; + + // Keep only competition events where this chapter has registered teams. + return _teamsByEventDefinitionId.TryGetValue(o.EventDefinitionId.Value, out var teams) && teams.Count > 0; + }) + .OrderBy(o => o.StartTime); + } + private IEnumerable GetEventSummaryRows(Student student) { foreach (var team in student.Teams.OrderBy(t => t.Event.Name))