Skip to content

Commit

Permalink
Merge pull request #150 from SaintAngeLs/frontend_update
Browse files Browse the repository at this point in the history
Frontend update
  • Loading branch information
an2508374 authored May 17, 2024
2 parents 166516f + fb640ea commit c648710
Show file tree
Hide file tree
Showing 28 changed files with 787 additions and 327 deletions.
29 changes: 27 additions & 2 deletions MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ public Task<EventDto> GetEventAsync(Guid eventId)
return _httpClient.GetAsync<EventDto>($"events/{eventId}");
}

public Task<PagedResponseDto<IEnumerable<EventDto>>> GetStudentEventsAsync(Guid studentId, int numberOfResults)
public Task<PagedResponseDto<IEnumerable<EventDto>>> GetStudentEventsAsync(Guid studentId,
string engagementType, int page, int numberOfResults)
{
_httpClient.SetAccessToken(_identityService.JwtDto.AccessToken);
return _httpClient.GetAsync<PagedResponseDto<IEnumerable<EventDto>>>(
$"events/student/{studentId}?numberOfResults={numberOfResults}");
$"events/student/{studentId}?engagementType={engagementType}&page={page}&numberOfResults={numberOfResults}");
}

public Task<HttpResponse<object>> AddEventAsync(Guid eventId, string name, Guid organizerId, Guid organizationId,
Expand All @@ -53,6 +54,12 @@ public Task<HttpResponse<object>> UpdateEventAsync(Guid eventId, string name, Gu
capacity, fee, category, publishDate});
}

public Task DeleteEventAsync(Guid eventId)
{
_httpClient.SetAccessToken(_identityService.JwtDto.AccessToken);
return _httpClient.DeleteAsync($"events/{eventId}");
}

public Task SignUpToEventAsync(Guid eventId, Guid studentId)
{
_httpClient.SetAccessToken(_identityService.JwtDto.AccessToken);
Expand Down Expand Up @@ -98,5 +105,23 @@ public Task<HttpResponse<PagedResponseDto<IEnumerable<EventDto>>>> SearchOrganiz
return _httpClient.PostAsync<SearchOrganizerEvents, PagedResponseDto<IEnumerable<EventDto>>>("events/search/organizer",
new (name, organizerId, dateFrom, dateTo, state, pageable));
}

public Task<EventParticipantsDto> GetEventParticipants(Guid eventId)
{
_httpClient.SetAccessToken(_identityService.JwtDto.AccessToken);
return _httpClient.GetAsync<EventParticipantsDto>($"events/{eventId}/participants");
}

public Task AddEventParticipant(Guid eventId, Guid studentId, string studentName)
{
_httpClient.SetAccessToken(_identityService.JwtDto.AccessToken);
return _httpClient.PostAsync($"events/{eventId}/participants", new {eventId, studentId, studentName});
}

public Task RemoveEventParticipant(Guid eventId, Guid participantId)
{
_httpClient.SetAccessToken(_identityService.JwtDto.AccessToken);
return _httpClient.DeleteAsync($"events/{eventId}/participants?participantId={participantId}");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace MiniSpace.Web.Areas.Events
public interface IEventsService
{
Task<EventDto> GetEventAsync(Guid eventId);
Task<PagedResponseDto<IEnumerable<EventDto>>> GetStudentEventsAsync(Guid studentId, int numberOfResults);
Task<PagedResponseDto<IEnumerable<EventDto>>> GetStudentEventsAsync(Guid studentId,
string engagementType, int page, int numberOfResults);
Task<HttpResponse<object>> AddEventAsync(Guid eventId, string name, Guid organizerId, Guid organizationId,
string startDate, string endDate, string buildingName, string street, string buildingNumber,
string apartmentNumber, string city, string zipCode, string description, int capacity, decimal fee,
Expand All @@ -20,6 +21,7 @@ Task<HttpResponse<object>> UpdateEventAsync(Guid eventId, string name, Guid orga
string startDate, string endDate, string buildingName, string street, string buildingNumber,
string apartmentNumber, string city, string zipCode, string description, int capacity, decimal fee,
string category, string publishDate);
Task DeleteEventAsync(Guid eventId);
Task SignUpToEventAsync(Guid eventId, Guid studentId);
Task CancelSignUpToEventAsync(Guid eventId, Guid studentId);
Task ShowInterestInEventAsync(Guid eventId, Guid studentId);
Expand All @@ -30,5 +32,8 @@ Task<HttpResponse<PagedResponseDto<IEnumerable<EventDto>>>> SearchEventsAsync(st
string dateTo, PageableDto pageable);
Task<HttpResponse<PagedResponseDto<IEnumerable<EventDto>>>> SearchOrganizerEventsAsync(Guid organizerId,
string name, string state, string dateFrom, string dateTo, PageableDto pageable);
Task<EventParticipantsDto> GetEventParticipants(Guid eventId);
Task AddEventParticipant(Guid eventId, Guid studentId, string studentName);
Task RemoveEventParticipant(Guid eventId, Guid participantId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public interface IStudentsService
Task UpdateStudentDto(Guid studentId);
void ClearStudentDto();
Task<StudentDto> GetStudentAsync(Guid studentId);
Task<IEnumerable<StudentDto>> GetStudentsAsync();
Task<PaginatedResponseDto<StudentDto>> GetStudentsAsync();
Task UpdateStudentAsync(Guid studentId, string profileImage, string description, bool emailNotifications);
Task<HttpResponse<object>> CompleteStudentRegistrationAsync(Guid studentId, string profileImage,
string description, DateTime dateOfBirth, bool emailNotifications);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public async Task<StudentDto> GetStudentAsync(Guid studentId)
return await _httpClient.GetAsync<StudentDto>($"students/{studentId}");
}

public Task<IEnumerable<StudentDto>> GetStudentsAsync()
public Task<PaginatedResponseDto<StudentDto>> GetStudentsAsync()
{
_httpClient.SetAccessToken(_identityService.JwtDto.AccessToken);
return _httpClient.GetAsync<IEnumerable<StudentDto>>("students");
return _httpClient.GetAsync<PaginatedResponseDto<StudentDto>>("students");
}

public Task UpdateStudentAsync(Guid studentId, string profileImage, string description, bool emailNotifications)
Expand Down
46 changes: 46 additions & 0 deletions MiniSpace.Web/src/MiniSpace.Web/Components/RadzenEventCard.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@using MiniSpace.Web.DTO
@inject NavigationManager NavigationManager

<RadzenCard Class="rz-border-radius-3" Style="cursor: pointer"
@onclick="@(() => NavigationManager.NavigateTo($"/events/{Event.Id}"))">
<RadzenRow Size="12">
<RadzenColumn Size="12" SizeMD="6">
<RadzenText TextStyle="TextStyle.Overline" class="rz-display-flex rz-mt-1 rz-my-0">Name</RadzenText>
<RadzenText TextStyle="TextStyle.Body1"><b>@(Event.Name)</b></RadzenText>
</RadzenColumn>
<RadzenColumn Size="12" SizeMD="5">
<RadzenText TextStyle="TextStyle.Overline" class="rz-display-flex rz-mt-1 rz-my-0">Status</RadzenText>
@switch (Event.Status)
{
case "Published":
<RadzenText TextStyle="TextStyle.Body1" Style="color: green"><b>@Event.Status</b></RadzenText>
break;
case "Archived":
<RadzenText TextStyle="TextStyle.Body1" Style="color: indianred"><b>@Event.Status</b></RadzenText>
break;
default:
<RadzenText TextStyle="TextStyle.Body1"><b>@Event.Status</b></RadzenText>
break;
}
</RadzenColumn>
</RadzenRow>
<RadzenRow Size="12">
<RadzenColumn Size="12" SizeMD="6">
<RadzenText TextStyle="TextStyle.Overline" class="rz-display-flex rz-mt-3 rz-mb-0">Start date</RadzenText>
<RadzenText TextStyle="TextStyle.Body1"><b>@(Event.StartDate.ToLocalTime().ToString(dateFormat))</b></RadzenText>
</RadzenColumn>
<RadzenColumn Size="12" SizeMD="5">
<RadzenText TextStyle="TextStyle.Overline" class="rz-display-flex rz-mt-3 rz-mb-0">End date</RadzenText>
<RadzenText TextStyle="TextStyle.Body1"><b>@(Event.EndDate.ToLocalTime().ToString(dateFormat))</b></RadzenText>
</RadzenColumn>
</RadzenRow>
<hr style="border: none; background-color: rgba(0,0,0,.2); height: 1px; margin: 1rem 0;"/>
</RadzenCard>

@code
{
[Parameter]
public EventDto Event { get; set; }

private const string dateFormat = "dd/MM/yyyy HH:mm";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;

namespace MiniSpace.Web.DTO.Wrappers
{
public class EventParticipantsDto
{
public Guid EventId { get; set; }
public IEnumerable<ParticipantDto> InterestedStudents { get; set; }
public IEnumerable<ParticipantDto> SignedUpStudents { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
{
var response = await StudentsService.CompleteStudentRegistrationAsync(completeRegistrationModel.StudentId,
completeRegistrationModel.ProfileImage, completeRegistrationModel.Description,
completeRegistrationModel.DateOfBirth, completeRegistrationModel.EmailNotifications);
completeRegistrationModel.DateOfBirth.ToUniversalTime(), completeRegistrationModel.EmailNotifications);
// Handle the post-sign-up logic, such as redirection or displaying a success message
if (response.ErrorMessage != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
Value="@studentDto.NumberOfFriends" Disabled="true"/>

<RadzenLabelWithDatePicker Id="date-of-birth" LabelText="Date of birth:"
Value="@studentDto.DateOfBirth" Disabled="true"/>
Value="@studentDto.DateOfBirth.ToLocalTime()" Disabled="true"/>

<RadzenLabelWithDatePicker Id="created-at" LabelText="Created at:"
Value="@studentDto.CreatedAt" Disabled="true"/>
Value="@studentDto.CreatedAt.ToLocalTime()" Disabled="true"/>

<RadzenLabelWithCheckbox Id="email-notifications" LabelText="Email notifications:"
@bind-Value="@studentDto.EmailNotifications" Disabled=@editionDisabled/>
Expand Down
59 changes: 0 additions & 59 deletions MiniSpace.Web/src/MiniSpace.Web/Pages/Account/UpdateAccount.razor

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@

<RadzenColumn Size="6">
<RadzenText TextStyle="TextStyle.Body2" class="rz-display-flex rz-mt-3 rz-my-0">Profile image</RadzenText>
<RadzenImage Path="@($"data:image/jpeg;base64,{@StudentDto.ProfileImage}")"
<RadzenImage Path="@($"data:image/jpeg;base64,{StudentDto.ProfileImage}")"
AlternateText="Not set"
Style="width: 5em" class="rz-border-radius-5"/>
</RadzenColumn>
Expand Down 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
16 changes: 13 additions & 3 deletions MiniSpace.Web/src/MiniSpace.Web/Pages/Admin/ManageStudents.razor
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,16 @@
<RadzenDataGridColumn Property="State" Title="State" Width="110px" TextAlign="TextAlign.Center" />
<RadzenDataGridColumn Property="IsBanned" Title="Is Banned" Width="110px" />
<RadzenDataGridColumn Property="IsOrganizer" Title="Is Organizer" Width="130px" />
<RadzenDataGridColumn Property="DateOfBirth" Title="Birth Date" FormatString="{0:d}" Width="120px" />
<RadzenDataGridColumn Property="CreatedAt" Title="Created At" Width="180px" />
<RadzenDataGridColumn Property="DateOfBirth" Title="Birth Date" FormatString="{0:d}" Width="120px">
<Template Context="student">
@student.DateOfBirth.ToLocalTime().ToString(shortDateFormat)
</Template>
</RadzenDataGridColumn>
<RadzenDataGridColumn Property="CreatedAt" Title="Created At" Width="180px">
<Template Context="student">
@student.CreatedAt.ToLocalTime().ToString(dateFormat)
</Template>
</RadzenDataGridColumn>
<RadzenDataGridColumn Property="Description" Title="Description" Width="150px" />
</Columns>
</RadzenDataGrid>
Expand All @@ -54,6 +62,7 @@

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

private int pageSize = 5;
IEnumerable<int> pageSizeOptions = new int[] { 5, 10, 20, 40};
Expand All @@ -70,7 +79,8 @@
{
adminId = IdentityService.GetCurrentUserId();

students = await StudentsService.GetStudentsAsync();
var paginatedResponse = await StudentsService.GetStudentsAsync();
students = paginatedResponse.Results;
totalStudents = students.Count();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@page "/events/{EventId}/delete"
@using MiniSpace.Web.Areas.Events
@using Radzen
@inject DialogService DialogService
@inject IEventsService EventsService
@inject NavigationManager NavigationManager

<RadzenStack Gap="1rem">

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

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

protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
}

private async void DeleteEvent(Guid eventId)
{
await EventsService.DeleteEventAsync(eventId);
DialogService.Close(true);
NavigationManager.NavigateTo("/events/organize");
}
}
Loading

0 comments on commit c648710

Please sign in to comment.