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))