diff --git a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs index ac117ae0c..ff7b5433b 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs @@ -53,6 +53,12 @@ public Task> 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); diff --git a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs index 66aac1c8a..cb99681c2 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs +++ b/MiniSpace.Web/src/MiniSpace.Web/Areas/Events/IEventsService.cs @@ -20,6 +20,7 @@ Task> 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); diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/DeleteEventDialog.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/DeleteEventDialog.razor new file mode 100644 index 000000000..9d50e22bf --- /dev/null +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Dialogs/DeleteEventDialog.razor @@ -0,0 +1,33 @@ +@page "/events/{EventId}/delete" +@using MiniSpace.Web.Areas.Events +@using Radzen +@inject DialogService DialogService +@inject IEventsService EventsService +@inject NavigationManager NavigationManager + + + + + + + + + + + +@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"); + } +} \ No newline at end of file diff --git a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Event.razor b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Event.razor index d6eb49452..73b088022 100644 --- a/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Event.razor +++ b/MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Event.razor @@ -97,7 +97,8 @@ - + @@ -334,6 +335,17 @@ }); } + private async Task OpenDeleteEventDialog(Guid postId) + { + await DialogService.OpenAsync("Are you sure? This action cannot be undone!", + new Dictionary() { {"EventId", new Guid(EventId) } }, + new DialogOptions() + { + Width = "500px", Height = "100px", Resizable = true, Draggable = true, + AutoFocusFirstElement = false + }); + } + private async Task OpenParticipantDetailsDialog(ParticipantDto participantDto, string term) { await DialogService.OpenAsync($"Details of the {term}:",