Add Event Calendar feature with event occurrences service integration

Introduced a new Event Calendar component that displays scheduled events using the Heron.MudCalendar. Implemented IEventOccurrenceService to fetch event occurrences, and added mock data for initial testing. Updated navigation menu to include a link to the Event Calendar.
This commit is contained in:
2025-12-27 13:25:17 -05:00
parent 5c1e0b7444
commit 9668ec162d
8 changed files with 231 additions and 0 deletions
@@ -0,0 +1,63 @@
@page "/event-calendar"
@attribute [Authorize]
@using WebApp.Components.Shared.Components
@using WebApp.Models
@using WebApp.Services
@using Heron.MudCalendar
@inject IEventOccurrenceService EventOccurrenceService
<PageHeader Title="Event Calendar" Description="View competition schedules and event occurrences" />
<MudPaper Elevation="2" Class="pa-6">
@if (_calendarItems == null)
{
<MudProgressLinear Indeterminate="true" />
<MudText>Loading calendar events...</MudText>
}
else
{
<MudCalendar T="CalendarEventItem"
Items="_calendarItems"
View="CalendarView.Day"
CurrentDay=_calendarDate
/>
}
</MudPaper>
@code {
private List<CalendarEventItem>? _calendarItems;
private DateTime _calendarDate = DateTime.Today;
protected override async Task OnInitializedAsync()
{
await LoadCalendarEvents();
}
private async Task LoadCalendarEvents()
{
var occurrences = await EventOccurrenceService.GetEventOccurrencesAsync();
_calendarItems = occurrences
.Select(occ => new CalendarEventItem(occ))
.ToList();
// Find the next date with events
_calendarDate = GetNextDateWithEvents();
}
private DateTime GetNextDateWithEvents()
{
if (_calendarItems == null || !_calendarItems.Any())
{
return DateTime.Today;
}
var today = DateTime.Today;
var nextEvent = _calendarItems
.Where(item => item.Start.Date >= today)
.OrderBy(item => item.Start)
.FirstOrDefault();
return nextEvent?.Start.Date ?? _calendarItems.OrderBy(item => item.Start).First().Start.Date;
}
}
@@ -17,6 +17,7 @@
<MudNavLink Href="/teams/handout" Icon="@Icons.Material.Filled.Print">Handout</MudNavLink>
</MudNavGroup>
<MudNavLink Href="/meeting-schedule/" Icon="@AppIcons.Scheduler">Schedule</MudNavLink>
<MudNavLink Href="/event-calendar" Icon="@Icons.Material.Filled.CalendarMonth">Event Calendar</MudNavLink>
<MudNavGroup Title="Team Building" Icon="@Icons.Material.Filled.GroupAdd" Expanded="true">
<MudNavLink Href="/students/event-ranking" Icon="@AppIcons.EventRank">Event Ranking</MudNavLink>
<MudNavLink Href="/teams/assignment" Icon="@AppIcons.TeamAssignment">Team Assignment</MudNavLink>
+1
View File
@@ -22,6 +22,7 @@
@using WebApp.Components.Features.Events
@using WebApp.Components.Features.Events.Components
@using WebApp.Components.Features.MeetingSchedule
@using WebApp.Components.Features.EventCalendar
@using MudBlazor
@using Core.Entities
@using Data