Skip to content

Commit

Permalink
(#433) wasm: update show account profile razor comp
Browse files Browse the repository at this point in the history
  • Loading branch information
SaintAngeLs committed Oct 12, 2024
1 parent 5c98bd9 commit c32f29f
Show file tree
Hide file tree
Showing 11 changed files with 426 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<StudentWithGalleryImagesDto> GetStudentWithGalleryImagesAsync(Guid studentId)
{
var accessToken = await _identityService.GetAccessTokenAsync();
Expand All @@ -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()
};
Expand Down
19 changes: 15 additions & 4 deletions MiniSpace.Web/src/Astravent.Web.Wasm/DTO/AvailableSettingsDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
}
1 change: 1 addition & 0 deletions MiniSpace.Web/src/Astravent.Web.Wasm/DTO/EducationDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

}
}
}
1 change: 1 addition & 0 deletions MiniSpace.Web/src/Astravent.Web.Wasm/DTO/WorkDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,58 @@
@using MudBlazor
@using System.Text.Json

<MudText Typo="Typo.h4" GutterBottom="true">Notifications</MudText>
<MudText Typo="Typo.h4" GutterBottom="true">Notification Preferences</MudText>

@if (IsLoading)
{
<MudProgressCircular Indeterminate="true" Color="Color.Primary" />
}
else
{
<MudStack>
<MudSwitch @bind-Checked="StudentWithGalleryImagesDto.Student.EmailNotifications" Label="Email Notifications" Color="Color.Primary" />
<MudSwitch @bind-Checked="StudentWithGalleryImagesDto.Student.EmailNotifications" Label="Enable Email Notifications" Color="Color.Primary" />

@if (StudentWithGalleryImagesDto.Student.EmailNotifications)
{
<MudSwitch @bind-Checked="NotificationPreferencesDto.AccountChanges" Label="Account Changes" Color="Color.Primary" />
<MudSwitch @bind-Checked="NotificationPreferencesDto.SystemLogin" Label="System Login" Color="Color.Primary" />
<MudSwitch @bind-Checked="NotificationPreferencesDto.NewEvent" Label="New Event" Color="Color.Primary" />
<MudSwitch @bind-Checked="NotificationPreferencesDto.InterestBasedEvents" Label="Interest Based Events" Color="Color.Primary" />
<MudSwitch @bind-Checked="NotificationPreferencesDto.EventNotifications" Label="Event Notifications" Color="Color.Primary" />
<MudSwitch @bind-Checked="NotificationPreferencesDto.CommentsNotifications" Label="Comments Notifications" Color="Color.Primary" />
<MudSwitch @bind-Checked="NotificationPreferencesDto.PostsNotifications" Label="Posts Notifications" Color="Color.Primary" />
<MudSwitch @bind-Checked="NotificationPreferencesDto.FriendsNotifications" Label="Friends Notifications" Color="Color.Primary" />
<MudPaper Class="p-3">
<MudText Typo="Typo.h5" GutterBottom="true">Account & Security</MudText>
<MudSwitch @bind-Checked="NotificationPreferencesDto.SystemLogin" Label="System Login Notifications" Color="Color.Primary" />
</MudPaper>

<MudPaper Class="p-3 mt-3">
<MudText Typo="Typo.h5" GutterBottom="true">Event Notifications</MudText>
<MudSwitch @bind-Checked="NotificationPreferencesDto.InterestBasedEvents" Label="Interest-Based Events" Color="Color.Primary" />
<MudSwitch @bind-Checked="NotificationPreferencesDto.EventNotifications" Label="General Event Notifications" Color="Color.Primary" />
<MudSwitch @bind-Checked="NotificationPreferencesDto.EventsIAmInterestedInNotification" Label="Events I'm Interested In" Color="Color.Primary" />
<MudSwitch @bind-Checked="NotificationPreferencesDto.EventsIAmSignedUpToNotification" Label="Events I'm Signed Up To" Color="Color.Primary" />
<MudSwitch @bind-Checked="NotificationPreferencesDto.EventNotificationForPeopleIFollow" Label="Event Notifications for People I Follow" Color="Color.Primary" />
</MudPaper>

<MudPaper Class="p-3 mt-3">
<MudText Typo="Typo.h5" GutterBottom="true">Post Notifications</MudText>
<MudSwitch @bind-Checked="NotificationPreferencesDto.PostsNotifications" Label="My Posts Notifications" Color="Color.Primary" />
<MudSwitch @bind-Checked="NotificationPreferencesDto.CommentsNotifications" Label="Comments on My Posts" Color="Color.Primary" />
<MudSwitch @bind-Checked="NotificationPreferencesDto.FriendsPosts" Label="Friends' Posts" Color="Color.Primary" />
<MudSwitch @bind-Checked="NotificationPreferencesDto.FriendsPostsNotifications" Label="Friends' Posts Notifications" Color="Color.Primary" />
<MudSwitch @bind-Checked="NotificationPreferencesDto.PostsRecommendation" Label="Post Recommendations" Color="Color.Primary" />
<MudSwitch @bind-Checked="NotificationPreferencesDto.PostsOfPeopleIFollowNotification" Label="Posts of People I Follow" Color="Color.Primary" />
</MudPaper>

<MudPaper Class="p-3 mt-3">
<MudText Typo="Typo.h5" GutterBottom="true">Friends & Requests</MudText>
<MudSwitch @bind-Checked="NotificationPreferencesDto.NewFriendsRequests" Label="New Friend Requests" Color="Color.Primary" />
<MudSwitch @bind-Checked="NotificationPreferencesDto.MyRequestsAccepted" Label="My Requests Accepted" Color="Color.Primary" />
</MudPaper>

<MudPaper Class="p-3 mt-3">
<MudText Typo="Typo.h5" GutterBottom="true">Recommendations</MudText>
<MudSwitch @bind-Checked="NotificationPreferencesDto.EventRecommendation" Label="Event Recommendations" Color="Color.Primary" />
<MudSwitch @bind-Checked="NotificationPreferencesDto.FriendsRecommendation" Label="Friends Recommendations" Color="Color.Primary" />
</MudPaper>
}
</MudStack>
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@SaveNotificationPreferencesAsync">Save preferences</MudButton>

<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@SaveNotificationPreferencesAsync" Class="mt-3">Save Preferences</MudButton>
}

@code {
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down
Loading

0 comments on commit c32f29f

Please sign in to comment.