diff --git a/MiniSpace.Web/src/Astravent.Web.Wasm/Areas/Students/StudentsService.cs b/MiniSpace.Web/src/Astravent.Web.Wasm/Areas/Students/StudentsService.cs index 441923914..080517aa6 100644 --- a/MiniSpace.Web/src/Astravent.Web.Wasm/Areas/Students/StudentsService.cs +++ b/MiniSpace.Web/src/Astravent.Web.Wasm/Areas/Students/StudentsService.cs @@ -134,19 +134,29 @@ public async Task UpdateUserNotificationPreferencesAsync(Guid studentId, Notific { studentId, emailNotifications, - preferencesDto.AccountChanges, preferencesDto.SystemLogin, - preferencesDto.NewEvent, preferencesDto.InterestBasedEvents, preferencesDto.EventNotifications, preferencesDto.CommentsNotifications, preferencesDto.PostsNotifications, - preferencesDto.FriendsNotifications + preferencesDto.EventRecommendation, + preferencesDto.FriendsRecommendation, + preferencesDto.FriendsPosts, + preferencesDto.PostsRecommendation, + preferencesDto.EventsIAmInterestedInNotification, + preferencesDto.EventsIAmSignedUpToNotification, + preferencesDto.PostsOfPeopleIFollowNotification, + preferencesDto.EventNotificationForPeopleIFollow, + preferencesDto.NewFriendsRequests, + preferencesDto.MyRequestsAccepted, + preferencesDto.FriendsPostsNotifications }; await _httpClient.PostAsync($"students/{studentId}/notifications", updatePreferencesData); } + + public async Task GetStudentWithGalleryImagesAsync(Guid studentId) { var accessToken = await _identityService.GetAccessTokenAsync(); @@ -172,9 +182,18 @@ public async Task UpdateUserSettingsAsync(Guid studentId, AvailableSettingsDto a InterestsVisibility = availableSettings.InterestsVisibility.ToString(), ContactEmailVisibility = availableSettings.ContactEmailVisibility.ToString(), PhoneNumberVisibility = availableSettings.PhoneNumberVisibility.ToString(), - ProfileImageVisibility = availableSettings.ProfileImageVisibility.ToString(), - BannerImageVisibility = availableSettings.BannerImageVisibility.ToString(), - GalleryVisibility = availableSettings.GalleryVisibility.ToString(), + ProfileImageVisibility = availableSettings.ProfileImageVisibility.ToString(), + BannerImageVisibility = availableSettings.BannerImageVisibility.ToString(), + GalleryVisibility = availableSettings.GalleryVisibility.ToString(), + ConnectionVisibility = availableSettings.ConnectionVisibility.ToString(), + FollowersVisibility = availableSettings.FollowersVisibility.ToString(), + FollowingVisibility = availableSettings.FollowingVisibility.ToString(), + MyPostsVisibility = availableSettings.MyPostsVisibility.ToString(), + ConnectionsPostsVisibility = availableSettings.ConnectionsPostsVisibility.ToString(), + MyRepostsVisibility = availableSettings.MyRepostsVisibility.ToString(), + RepostsOfMyConnectionsVisibility = availableSettings.RepostsOfMyConnectionsVisibility.ToString(), + OrganizationIAmCreatorVisibility = availableSettings.OrganizationIAmCreatorVisibility.ToString(), + OrganizationIFollowVisibility = availableSettings.OrganizationIFollowVisibility.ToString(), PreferredLanguage = availableSettings.PreferredLanguage.ToString(), FrontendVersion = availableSettings.FrontendVersion.ToString() }; diff --git a/MiniSpace.Web/src/Astravent.Web.Wasm/DTO/AvailableSettingsDto.cs b/MiniSpace.Web/src/Astravent.Web.Wasm/DTO/AvailableSettingsDto.cs index 5d58ddbc3..83ef3b68c 100644 --- a/MiniSpace.Web/src/Astravent.Web.Wasm/DTO/AvailableSettingsDto.cs +++ b/MiniSpace.Web/src/Astravent.Web.Wasm/DTO/AvailableSettingsDto.cs @@ -12,10 +12,21 @@ public class AvailableSettingsDto public Visibility InterestsVisibility { get; set; } public Visibility ContactEmailVisibility { get; set; } public Visibility PhoneNumberVisibility { get; set; } - public Visibility ProfileImageVisibility { get; set; } - public Visibility BannerImageVisibility { get; set; } - public Visibility GalleryVisibility { get; set; } + public Visibility ProfileImageVisibility { get; set; } + public Visibility BannerImageVisibility { get; set; } + public Visibility GalleryVisibility { get; set; } + + public Visibility ConnectionVisibility { get; set; } + public Visibility FollowersVisibility { get; set; } + public Visibility FollowingVisibility { get; set; } + public Visibility MyPostsVisibility { get; set; } + public Visibility ConnectionsPostsVisibility { get; set; } + public Visibility MyRepostsVisibility { get; set; } + public Visibility RepostsOfMyConnectionsVisibility { get; set; } + public Visibility OrganizationIAmCreatorVisibility { get; set; } + public Visibility OrganizationIFollowVisibility { get; set; } + public PreferredLanguage PreferredLanguage { get; set; } public FrontendVersion FrontendVersion { get; set; } } -} \ No newline at end of file +} diff --git a/MiniSpace.Web/src/Astravent.Web.Wasm/DTO/EducationDto.cs b/MiniSpace.Web/src/Astravent.Web.Wasm/DTO/EducationDto.cs index aff4c09aa..092f70426 100644 --- a/MiniSpace.Web/src/Astravent.Web.Wasm/DTO/EducationDto.cs +++ b/MiniSpace.Web/src/Astravent.Web.Wasm/DTO/EducationDto.cs @@ -4,6 +4,7 @@ namespace Astravent.Web.Wasm.DTO { public class EducationDto { + public Guid OrganizationId { get; set; } public string InstitutionName { get; set; } public string Degree { get; set; } public DateTime? StartDate { get; set; } = null; diff --git a/MiniSpace.Web/src/Astravent.Web.Wasm/DTO/NotificationPreferencesDto.cs b/MiniSpace.Web/src/Astravent.Web.Wasm/DTO/NotificationPreferencesDto.cs index 2f1d9d318..bb67fb82c 100644 --- a/MiniSpace.Web/src/Astravent.Web.Wasm/DTO/NotificationPreferencesDto.cs +++ b/MiniSpace.Web/src/Astravent.Web.Wasm/DTO/NotificationPreferencesDto.cs @@ -6,13 +6,24 @@ namespace Astravent.Web.Wasm.DTO public class NotificationPreferencesDto { public Guid UserId { get; set; } - public bool AccountChanges { get; set; } public bool SystemLogin { get; set; } - public bool NewEvent { get; set; } public bool InterestBasedEvents { get; set; } public bool EventNotifications { get; set; } public bool CommentsNotifications { get; set; } public bool PostsNotifications { get; set; } - public bool FriendsNotifications { get; set; } + + public bool EventRecommendation { get; set; } + public bool FriendsRecommendation { get; set; } + public bool FriendsPosts { get; set; } + public bool PostsRecommendation { get; set; } + public bool EventsIAmInterestedInNotification { get; set; } + public bool EventsIAmSignedUpToNotification { get; set; } + public bool PostsOfPeopleIFollowNotification { get; set; } + public bool EventNotificationForPeopleIFollow { get; set; } + + public bool NewFriendsRequests { get; set; } + public bool MyRequestsAccepted { get; set; } + public bool FriendsPostsNotifications { get; set; } + } -} \ No newline at end of file +} diff --git a/MiniSpace.Web/src/Astravent.Web.Wasm/DTO/WorkDto.cs b/MiniSpace.Web/src/Astravent.Web.Wasm/DTO/WorkDto.cs index b44a8cde0..93b69daf3 100644 --- a/MiniSpace.Web/src/Astravent.Web.Wasm/DTO/WorkDto.cs +++ b/MiniSpace.Web/src/Astravent.Web.Wasm/DTO/WorkDto.cs @@ -4,6 +4,7 @@ namespace Astravent.Web.Wasm.DTO { public class WorkDto { + public Guid OrganizationId { get; set; } public string Company { get; set; } public string Position { get; set; } public DateTime? StartDate { get; set; } = null; diff --git a/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Account/NotificationsSettingsComponent.razor b/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Account/NotificationsSettingsComponent.razor index a5720eba5..8724a37ee 100644 --- a/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Account/NotificationsSettingsComponent.razor +++ b/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Account/NotificationsSettingsComponent.razor @@ -7,7 +7,8 @@ @using MudBlazor @using System.Text.Json -Notifications +Notification Preferences + @if (IsLoading) { @@ -15,20 +16,49 @@ else { - + + @if (StudentWithGalleryImagesDto.Student.EmailNotifications) { - - - - - - - - + + Account & Security + + + + + Event Notifications + + + + + + + + + Post Notifications + + + + + + + + + + Friends & Requests + + + + + + Recommendations + + + } - Save preferences + + Save Preferences } @code { @@ -46,7 +76,7 @@ else IsLoading = true; try { - var studentId = await IdentityService.GetCurrentUserIdFromJwtAsync(); // Correct method to get user ID from JWT + var studentId = await IdentityService.GetCurrentUserIdFromJwtAsync(); StudentWithGalleryImagesDto = await StudentsService.GetStudentWithGalleryImagesAsync(studentId); NotificationPreferencesDto = await StudentsService.GetUserNotificationPreferencesAsync(studentId); } @@ -64,7 +94,7 @@ else { try { - var studentId = await IdentityService.GetCurrentUserIdFromJwtAsync(); // Correct method to get user ID from JWT + var studentId = await IdentityService.GetCurrentUserIdFromJwtAsync(); await StudentsService.UpdateUserNotificationPreferencesAsync(studentId, NotificationPreferencesDto, StudentWithGalleryImagesDto.Student.EmailNotifications); Snackbar.Add("Notification preferences updated successfully.", Severity.Success); } diff --git a/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Account/ProfileComponent.razor b/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Account/ProfileComponent.razor index 25aa1c044..ca355ba45 100644 --- a/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Account/ProfileComponent.razor +++ b/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Account/ProfileComponent.razor @@ -2,12 +2,15 @@ @inject IIdentityService IdentityService @inject IStudentsService StudentsService @inject IMediaFilesService MediaFilesService +@inject IOrganizationsService OrganizationsService @inject IJSRuntime JSRuntime @inject NavigationManager NavigationManager @using Astravent.Web.Wasm.Utilities +@using Astravent.Web.Wasm.Pages.Reports.Dialogs @using System.IO @using MudBlazor @using System +@using System.Text.Json Profile @if (IsLoading) @@ -101,6 +104,9 @@ else { + + + @@ -122,7 +128,13 @@ else - + + Associate with Organization + + Remove @@ -141,6 +153,9 @@ else { + + + @@ -162,7 +177,13 @@ else - + + Associate with Organization + + Remove @@ -235,17 +256,35 @@ else [Parameter] public EventCallback SaveChangesAsync { get; set; } [Parameter] public EventCallback SaveImageAsync { get; set; } [Parameter] public bool IsUploading { get; set; } + [Inject] public IDialogService DialogService { get; set; } private string CroppedImageBase64 { get; set; } + private IBrowserFile croppedImageFile; private string currentImageType = string.Empty; + private Dictionary _organizationImages = new(); + protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { await JSRuntime.InvokeVoidAsync("GLOBAL.SetDotnetReference", DotNetObjectReference.Create(this)); } + await LoadOrganizationImagesAsync(); + } + + private async Task LoadOrganizationImagesAsync() + { + foreach (var education in StudentWithGalleryImagesDto.Student.Education) + { + _organizationImages[education.OrganizationId] = await GetOrganizationImage(education.OrganizationId); + } + + foreach (var work in StudentWithGalleryImagesDto.Student.Work) + { + _organizationImages[work.OrganizationId] = await GetOrganizationImage(work.OrganizationId); + } } private string GetImage() @@ -380,6 +419,7 @@ else var educationList = StudentWithGalleryImagesDto.Student.Education.ToList(); educationList.Add(new EducationDto { + OrganizationId = Guid.Empty, InstitutionName = string.Empty, Degree = string.Empty, StartDate = null, @@ -404,6 +444,7 @@ else var workList = StudentWithGalleryImagesDto.Student.Work.ToList(); workList.Add(new WorkDto { + OrganizationId = Guid.Empty, Company = string.Empty, Position = string.Empty, StartDate = null, // Initialize as null @@ -425,22 +466,88 @@ else } private async Task SaveProfile() +{ + var studentDto = StudentWithGalleryImagesDto.Student; + + try { - // Ensure dates are correct before saving - foreach (var education in StudentWithGalleryImagesDto.Student.Education) + // Log Education JSON + var educationJson = JsonSerializer.Serialize(studentDto.Education, new JsonSerializerOptions { WriteIndented = true }); + Console.WriteLine("Education Data (Before Sending):"); + Console.WriteLine(educationJson); + + // Log Work JSON + var workJson = JsonSerializer.Serialize(studentDto.Work, new JsonSerializerOptions { WriteIndented = true }); + Console.WriteLine("Work Data (Before Sending):"); + Console.WriteLine(workJson); + + // Proceed to save changes + await SaveChangesAsync.InvokeAsync(null); + } + catch (Exception ex) + { + Console.WriteLine($"An error occurred: {ex.Message}"); + } +} + + + + private async Task OpenAssociateOrganizationDialog(string type, object entity) + { + var parameters = new DialogParameters + { + { "Type", type }, + { "Entity", entity } + }; + + var dialog = DialogService.Show("Associate with Organization", parameters); + var result = await dialog.Result; + + if (!result.Cancelled) + { + // Update the entity with the selected organization + var organization = (OrganizationDto)result.Data; + if (type == "Education") + { + var education = (EducationDto)entity; + education.OrganizationId = organization.Id; + education.InstitutionName = organization.Name; + } + else if (type == "Work") + { + var work = (WorkDto)entity; + work.OrganizationId = organization.Id; + work.Company = organization.Name; + } + } + } + + private async Task GetOrganizationImage(Guid organizationId) + { + if (organizationId == Guid.Empty) { - // Log the values to verify correctness - Console.WriteLine($"Before Save - Education StartDate: {education.StartDate}, EndDate: {education.EndDate}"); + return "images/default_org_image.png"; } - foreach (var work in StudentWithGalleryImagesDto.Student.Work) + if (_organizationImages.ContainsKey(organizationId)) { - // Log the values to verify correctness - Console.WriteLine($"Before Save - Work StartDate: {work.StartDate}, EndDate: {work.EndDate}"); + return _organizationImages[organizationId]; } + var organization = await OrganizationsService.GetOrganizationAsync(organizationId); + var imageUrl = organization?.ImageUrl ?? "images/default_org_image.png"; + _organizationImages[organizationId] = imageUrl; - // Invoke the parent method to save changes - await SaveChangesAsync.InvokeAsync(null); + return imageUrl; + } + + private string GetOrganizationImageSafe(Guid organizationId) + { + if (!_organizationImages.ContainsKey(organizationId)) + { + return "images/default_org_image.png"; + } + + return _organizationImages[organizationId]; } } diff --git a/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Account/UserSettingsComponent.razor b/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Account/UserSettingsComponent.razor index 09aec162f..38eb91d78 100644 --- a/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Account/UserSettingsComponent.razor +++ b/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Account/UserSettingsComponent.razor @@ -10,6 +10,7 @@ else { + @@ -94,11 +95,11 @@ else - - + + - @foreach (Visibility visibility in Enum.GetValues(typeof(Visibility))) { @@ -107,7 +108,25 @@ else - + @foreach (Visibility visibility in Enum.GetValues(typeof(Visibility))) + { + @visibility + } + + + + + @foreach (Visibility visibility in Enum.GetValues(typeof(Visibility))) + { + @visibility + } + + + + @foreach (Visibility visibility in Enum.GetValues(typeof(Visibility))) { @@ -115,14 +134,8 @@ else } - - - - - - - @foreach (Visibility visibility in Enum.GetValues(typeof(Visibility))) { @@ -131,7 +144,31 @@ else - + @foreach (Visibility visibility in Enum.GetValues(typeof(Visibility))) + { + @visibility + } + + + + + @foreach (Visibility visibility in Enum.GetValues(typeof(Visibility))) + { + @visibility + } + + + + + + + + + + @foreach (Visibility visibility in Enum.GetValues(typeof(Visibility))) { @@ -140,7 +177,7 @@ else - @foreach (Visibility visibility in Enum.GetValues(typeof(Visibility))) { diff --git a/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Events/Components/EventItem.razor b/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Events/Components/EventItem.razor index 3d79f2554..770476926 100644 --- a/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Events/Components/EventItem.razor +++ b/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Events/Components/EventItem.razor @@ -4,6 +4,7 @@ @using Astravent.Web.Wasm.Pages.Reports.Dialogs @inject IDialogService DialogService @inject IIdentityService IdentityService +@inject NavigationManager NavigationManager @code { [Parameter] public EventDto Event { get; set; } @@ -77,7 +78,26 @@ - + + + Share on Facebook + + + Share on Twitter + + + Share on WhatsApp + + + Share on LinkedIn + + + Invite + + + Report + + @@ -152,4 +172,30 @@ ? "Organization Event" : "User Event"; } + + private void ShareEvent(string platform) + { + var eventUrl = NavigationManager.Uri; + var eventTitle = Uri.EscapeDataString(Event.Name); + + string shareUrl = platform switch + { + "facebook" => $"https://www.facebook.com/sharer/sharer.php?u={eventUrl}", + "twitter" => $"https://twitter.com/intent/tweet?text={eventTitle}&url={eventUrl}", + "whatsapp" => $"https://wa.me/?text={eventTitle}%20{eventUrl}", + "linkedin" => $"https://www.linkedin.com/shareArticle?mini=true&url={eventUrl}&title={eventTitle}", + _ => "" + }; + + if (!string.IsNullOrEmpty(shareUrl)) + { + NavigationManager.NavigateTo(shareUrl, true); + } + } + + + private void InviteToEvent() + { + // Logic to invite others to the event + } } diff --git a/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Reports/Dialogs/AssociateOrganizationDialog.razor b/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Reports/Dialogs/AssociateOrganizationDialog.razor new file mode 100644 index 000000000..9c1d6bd67 --- /dev/null +++ b/MiniSpace.Web/src/Astravent.Web.Wasm/Pages/Reports/Dialogs/AssociateOrganizationDialog.razor @@ -0,0 +1,110 @@ +@inject IOrganizationsService OrganizationsService +@inject ISnackbar Snackbar + + + + Associate with Organization + + + + + + + + + @if (Organizations?.Any() == true) + { + @foreach (var org in Organizations) + { + + +
+ + + + + + + + @org.Name + @org.City, @org.Country + + + + @TruncateDescription(org.Description, 80) + + + +
+
+ } + } + else + { + No organizations found. Try a different search. + } +
+ + + + Enter Organization Manually + +
+ + + Cancel + +
+ +@code { + [CascadingParameter] MudDialogInstance MudDialog { get; set; } + [Parameter] public string Type { get; set; } // "Education" or "Work" + [Parameter] public object Entity { get; set; } // The associated entity (EducationDto or WorkDto) + + private string SearchQuery { get; set; } = string.Empty; + private IEnumerable Organizations { get; set; } = new List(); + + // Fetch organizations based on search query + private async Task PerformSearch() + { + if (!string.IsNullOrWhiteSpace(SearchQuery)) + { + var pagedResult = await OrganizationsService.GetPaginatedOrganizationsAsync(1, 10, SearchQuery); + Organizations = pagedResult.Items; + } + } + + // This method gets called when the organization is selected + private void SelectOrganization(OrganizationDto organization) + { + MudDialog.Close(DialogResult.Ok(organization)); // Return the selected organization as dialog result + } + + // This method adds a custom organization manually + private void AddCustomOrganization() + { + var customOrganization = new OrganizationDto + { + Name = SearchQuery + }; + MudDialog.Close(DialogResult.Ok(customOrganization)); + } + + // Close the dialog without selecting an organization + private void CloseDialog() + { + MudDialog.Cancel(); + } + + // Helper method to truncate text descriptions + private string TruncateDescription(string description, int maxLength) + { + if (string.IsNullOrEmpty(description)) + { + return string.Empty; + } + return description.Length <= maxLength ? description : description.Substring(0, maxLength) + "..."; + } +} diff --git a/MiniSpace.Web/src/Astravent.Web.Wasm/_Imports.razor b/MiniSpace.Web/src/Astravent.Web.Wasm/_Imports.razor index f27f7edf0..a127ed750 100644 --- a/MiniSpace.Web/src/Astravent.Web.Wasm/_Imports.razor +++ b/MiniSpace.Web/src/Astravent.Web.Wasm/_Imports.razor @@ -61,3 +61,4 @@ @using Astravent.Web.Wasm.Areas.Reports @using Astravent.Web.Wasm.Areas.Reports.CommandsDto @using Astravent.Web.Wasm.Pages.Reports.Dialogs +