Skip to content

Commit

Permalink
(#57) add showing signed up and interested friends in event
Browse files Browse the repository at this point in the history
  • Loading branch information
an2508374 committed May 16, 2024
1 parent 9734ae1 commit baa3c4d
Show file tree
Hide file tree
Showing 3 changed files with 223 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
<RadzenRow Size="12">
<RadzenColumn Size="6">
<RadzenText TextStyle="TextStyle.Body2" class="rz-display-flex rz-mt-3 rz-my-0">Date of birth</RadzenText>
<RadzenText TextStyle="TextStyle.H6"><b>@(StudentDto.DateOfBirth.ToLocalTime().ToString(dateFormat))</b></RadzenText>
<RadzenText TextStyle="TextStyle.H6"><b>@(StudentDto.DateOfBirth.ToLocalTime().ToString(shortDateFormat))</b></RadzenText>
</RadzenColumn>

<RadzenColumn Size="6">
Expand Down Expand Up @@ -172,6 +172,7 @@
public StudentDto StudentDto { get; set; }

private const string dateFormat = "dd/MM/yyyy HH:mm";
private const string shortDateFormat = "dd/MM/yyyy";

protected override async Task OnInitializedAsync()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
@page "/events/{EventId}/participants/{ParticipantDto.Id}/details"
@using MiniSpace.Web.Areas.Students
@using Radzen
@using MiniSpace.Web.DTO
@inject DialogService DialogService
@inject IIdentityService IdentityService
@inject IStudentsService StudentsService

@if (dialogInitialized)
{
<RadzenStack Gap="1rem">
<RadzenFieldset>
<HeaderTemplate>
<RadzenStack Gap="0" Orientation="Orientation.Horizontal">
<RadzenIcon Icon="account_box" class="me-1"/>
<b>Identification</b>
</RadzenStack>
</HeaderTemplate>
<ChildContent>
<RadzenStack Gap="2rem">
<RadzenRow Size="12" AlignItems="AlignItems.Center">
<RadzenColumn Size="12">
<RadzenStack Orientation="Orientation.Horizontal" JustifyContent="JustifyContent.Center">
<RadzenImage Path="@($"data:image/jpeg;base64,{studentDto.ProfileImage}")"
AlternateText="Not set"
Style="width: 8em" class="rz-border-radius-5"/>
</RadzenStack>
</RadzenColumn>
</RadzenRow>

<RadzenRow AlignItems="AlignItems.Center">
<RadzenColumn Size="12" SizeMD="12">

</RadzenColumn>
</RadzenRow>
</RadzenStack>
</ChildContent>
</RadzenFieldset>

<RadzenFieldset>
<HeaderTemplate>
<RadzenStack Gap="0" Orientation="Orientation.Horizontal">
<RadzenIcon Icon="face" class="me-1"/>
<b>Personal info</b>
</RadzenStack>
</HeaderTemplate>
<ChildContent>
<RadzenStack>
<RadzenRow Size="12" AlignItems="AlignItems.Center">
<RadzenColumn Size="6">
<RadzenText TextStyle="TextStyle.Body2" class="rz-display-flex rz-mt-3 rz-my-0">First name</RadzenText>
<RadzenText TextStyle="TextStyle.H6"><b>@(studentDto.FirstName)</b></RadzenText>
</RadzenColumn>

<RadzenColumn Size="6">
<RadzenText TextStyle="TextStyle.Body2" class="rz-display-flex rz-mt-3 rz-my-0">Last name</RadzenText>
<RadzenText TextStyle="TextStyle.H6"><b>@(studentDto.LastName)</b></RadzenText>
</RadzenColumn>
</RadzenRow>

<RadzenRow Size="12">
<RadzenColumn Size="6">
<RadzenText TextStyle="TextStyle.Body2" class="rz-display-flex rz-mt-3 rz-my-0">Email</RadzenText>
<RadzenText TextStyle="TextStyle.H6"><b>@(studentDto.Email)</b></RadzenText>
</RadzenColumn>

<RadzenColumn Size="6">
<RadzenText TextStyle="TextStyle.Body2" class="rz-display-flex rz-mt-3 rz-my-0">Description</RadzenText>
<RadzenText TextStyle="TextStyle.H6"><b>@(studentDto.Description)</b></RadzenText>
</RadzenColumn>
</RadzenRow>

<RadzenRow AlignItems="AlignItems.Center">
<RadzenColumn Size="12" SizeMD="12">

</RadzenColumn>
</RadzenRow>
</RadzenStack>
</ChildContent>
</RadzenFieldset>

<RadzenFieldset>
<HeaderTemplate>
<RadzenStack Gap="0" Orientation="Orientation.Horizontal">
<RadzenIcon Icon="event" class="me-1"/>
<b>Other info</b>
</RadzenStack>
</HeaderTemplate>
<ChildContent>
<RadzenStack>
<RadzenRow Size="12" AlignItems="AlignItems.Center">
<RadzenColumn Size="6">
<RadzenText TextStyle="TextStyle.Body2" class="rz-display-flex rz-mt-3 rz-my-0">Status</RadzenText>
<RadzenText TextStyle="TextStyle.H6"><b>@(studentDto.State.Normalize())</b></RadzenText>
</RadzenColumn>

<RadzenColumn Size="6">
<RadzenText TextStyle="TextStyle.Body2" class="rz-display-flex rz-mt-3 rz-my-0">Email notifications</RadzenText>
<RadzenText TextStyle="TextStyle.H6"><b>@(studentDto.EmailNotifications)</b></RadzenText>
</RadzenColumn>
</RadzenRow>

<RadzenRow Size="12">
<RadzenColumn Size="6">
<RadzenText TextStyle="TextStyle.Body2" class="rz-display-flex rz-mt-3 rz-my-0">Date of birth</RadzenText>
<RadzenText TextStyle="TextStyle.H6"><b>@(studentDto.DateOfBirth.ToLocalTime().ToString(shortDateFormat))</b></RadzenText>
</RadzenColumn>

<RadzenColumn Size="6">
<RadzenText TextStyle="TextStyle.Body2" class="rz-display-flex rz-mt-3 rz-my-0">Created at</RadzenText>
<RadzenText TextStyle="TextStyle.H6"><b>@(studentDto.CreatedAt.ToLocalTime().ToString(dateFormat))</b></RadzenText>
</RadzenColumn>
</RadzenRow>

<RadzenRow AlignItems="AlignItems.Center">
<RadzenColumn Size="12" SizeMD="12">

</RadzenColumn>
</RadzenRow>
</RadzenStack>
</ChildContent>
</RadzenFieldset>

<RadzenStack Gap="1rem" Orientation="Orientation.Vertical" JustifyContent="JustifyContent.SpaceBetween" Style="height: 100%;">
<RadzenStack Orientation="Orientation.Horizontal" JustifyContent="JustifyContent.Center" Gap="0.5rem">
<RadzenButton Click="@(() => DialogService.Close(true))" Variant="Variant.Flat" Text="Close" Style="width: 120px"/>
</RadzenStack>
</RadzenStack>
</RadzenStack>
}

@code {
[Parameter]
public string EventId { get; set; }
[Parameter]
public ParticipantDto ParticipantDto { get; set; }

private StudentDto studentDto = new();
private bool dialogInitialized = false;

private const string dateFormat = "dd/MM/yyyy HH:mm";
private const string shortDateFormat = "dd/MM/yyyy";

protected override async Task OnInitializedAsync()
{
studentDto = await StudentsService.GetStudentAsync(ParticipantDto.StudentId);
await base.OnInitializedAsync();
dialogInitialized = true;
}
}
85 changes: 71 additions & 14 deletions MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Event.razor
Original file line number Diff line number Diff line change
Expand Up @@ -160,28 +160,64 @@

@if (IdentityService.IsAuthenticated && !IsUserEventOrganizer(ev))
{
<RadzenTabsItem Text="Signed up friends">
<RadzenDataGrid AllowFiltering="true" AllowColumnResize="true" AllowAlternatingRows="false"
AllowSorting="true" PageSize="@participantPageSize" PageSizeOptions="@participantPageSizeOptions"
AllowPaging="true" PagerHorizontalAlign="HorizontalAlign.Center" ShowPagingSummary="true"
Data="@ev.FriendsSignedUp" ColumnWidth="100px" LogicalFilterOperator="LogicalFilterOperator.Or">
<Columns>
<RadzenDataGridColumn Property="Name" Title="Name" Frozen="true" TextAlign="TextAlign.Center" />
<RadzenDataGridColumn Context="friend" Title="Options" TextAlign="TextAlign.Center"
Filterable="false" Sortable="false" Frozen="true">
<Template Context="friend">
<RadzenButton Size="ButtonSize.Medium" Text="Show"
ButtonStyle="ButtonStyle.Secondary"
Click="@(() => OpenParticipantDetailsDialog(friend, "friend"))" />
</Template>
</RadzenDataGridColumn>
</Columns>
</RadzenDataGrid>
</RadzenTabsItem>

<RadzenTabsItem Text="Interested friends">
</RadzenTabsItem>
<RadzenDataGrid AllowFiltering="true" AllowColumnResize="true" AllowAlternatingRows="false"
AllowSorting="true" PageSize="@participantPageSize" PageSizeOptions="@participantPageSizeOptions"
AllowPaging="true" PagerHorizontalAlign="HorizontalAlign.Center" ShowPagingSummary="true"
Data="@ev.FriendsInterestedIn" ColumnWidth="100px" LogicalFilterOperator="LogicalFilterOperator.Or">
<Columns>
<RadzenDataGridColumn Property="Name" Title="Name" Frozen="true" TextAlign="TextAlign.Center" />
<RadzenDataGridColumn Context="friend" Title="Options" TextAlign="TextAlign.Center"
Filterable="false" Sortable="false" Frozen="true">
<Template Context="friend">
<RadzenButton Size="ButtonSize.Medium" Text="Show"
ButtonStyle="ButtonStyle.Secondary"
Click="@(() => OpenParticipantDetailsDialog(friend, "friend"))" />
</Template>
</RadzenDataGridColumn>
</Columns>
</RadzenDataGrid>
</RadzenTabsItem>
}

@if (IdentityService.IsAuthenticated && IsUserEventOrganizer(ev))
{
<RadzenTabsItem Text="Signed up students">
<RadzenDataGrid @ref="signedUpDataGrid"
AllowFiltering="true" AllowColumnResize="true" AllowAlternatingRows="false"
FilterMode="FilterMode.Advanced" AllowSorting="true" PageSize="@participantPageSize"
PageSizeOptions="@participantPageSizeOptions"
AllowSorting="true" PageSize="@participantPageSize" PageSizeOptions="@participantPageSizeOptions"
AllowPaging="true" PagerHorizontalAlign="HorizontalAlign.Center" ShowPagingSummary="true"
Data="@signedUpStudents" ColumnWidth="300px" LogicalFilterOperator="LogicalFilterOperator.Or">
Data="@signedUpStudents" ColumnWidth="100px" LogicalFilterOperator="LogicalFilterOperator.Or">
<Columns>
<RadzenDataGridColumn Property="StudentId" Title="Student Id" Frozen="true" Width="150px" TextAlign="TextAlign.Center" />
<RadzenDataGridColumn Property="Name" Title="Name" Frozen="true" Width="150px" TextAlign="TextAlign.Center" />
<RadzenDataGridColumn Context="participant" Title="Options" Width="100px" TextAlign="TextAlign.Center"
<RadzenDataGridColumn Property="Name" Title="Name" Frozen="true" TextAlign="TextAlign.Center" />
<RadzenDataGridColumn Context="participant" Title="Options" TextAlign="TextAlign.Center"
Filterable="false" Sortable="false" Frozen="true">
<Template Context="participant">
<RadzenButton Size="ButtonSize.Medium" Text="Show"
ButtonStyle="ButtonStyle.Secondary"
Click="@(() => OpenParticipantDetailsDialog(participant, "participant"))" />
<RadzenButton Size="ButtonSize.Medium" Text="Remove"
ButtonStyle="ButtonStyle.Warning"
Click="@(() => RemoveEventParticipant(ev, participant))" />
Click="@(() => RemoveEventParticipant(ev, participant))"/>
</Template>
</RadzenDataGridColumn>
</Columns>
Expand All @@ -190,13 +226,19 @@

<RadzenTabsItem Text="Interested students">
<RadzenDataGrid AllowFiltering="true" AllowColumnResize="true" AllowAlternatingRows="false"
FilterMode="FilterMode.Advanced" AllowSorting="true" PageSize="@participantPageSize"
PageSizeOptions="@participantPageSizeOptions"
AllowSorting="true" PageSize="@participantPageSize" PageSizeOptions="@participantPageSizeOptions"
AllowPaging="true" PagerHorizontalAlign="HorizontalAlign.Center" ShowPagingSummary="true"
Data="@interestedStudents" ColumnWidth="300px" LogicalFilterOperator="LogicalFilterOperator.Or">
Data="@interestedStudents" ColumnWidth="100px" LogicalFilterOperator="LogicalFilterOperator.Or">
<Columns>
<RadzenDataGridColumn Property="StudentId" Title="Student Id" Frozen="true" Width="150px" TextAlign="TextAlign.Center" />
<RadzenDataGridColumn Property="Name" Title="Name" Frozen="true" Width="150px" TextAlign="TextAlign.Center" />
<RadzenDataGridColumn Property="Name" Title="Name" Frozen="true" TextAlign="TextAlign.Center" />
<RadzenDataGridColumn Context="participant" Title="Options" TextAlign="TextAlign.Center"
Filterable="false" Sortable="false" Frozen="true">
<Template Context="participant">
<RadzenButton Size="ButtonSize.Medium" Text="Show"
ButtonStyle="ButtonStyle.Secondary"
Click="@(() => OpenParticipantDetailsDialog(participant, "participant"))" />
</Template>
</RadzenDataGridColumn>
</Columns>
</RadzenDataGrid>
</RadzenTabsItem>
Expand Down Expand Up @@ -292,6 +334,21 @@
});
}

private async Task OpenParticipantDetailsDialog(ParticipantDto participantDto, string term)
{
await DialogService.OpenAsync<ParticipantDetailsDialog>($"Details of the {term}:",
new Dictionary<string, object>()
{
{ "EventId", EventId },
{ "ParticipantDto", participantDto }
},
new DialogOptions()
{
Width = "700px", Height = "600px", Resizable = true, Draggable = true,
AutoFocusFirstElement = false
});
}

private async void SignUpToEvent(EventDto eventDto)
{
await EventsService.SignUpToEventAsync(eventDto.Id, studentId);
Expand Down Expand Up @@ -322,7 +379,7 @@

private async void RemoveEventParticipant(EventDto eventDto, ParticipantDto participant)
{
await EventsService.RemoveEventParticipant(ev.Id, participant.StudentId);
await EventsService.RemoveEventParticipant(eventDto.Id, participant.StudentId);
signedUpStudents.Remove(participant);
await signedUpDataGrid.Reload();
}
Expand Down

0 comments on commit baa3c4d

Please sign in to comment.