Skip to content

Commit

Permalink
feat(templates): implement new design of Settings page of Boilerplate #…
Browse files Browse the repository at this point in the history
  • Loading branch information
msynk authored Oct 11, 2024
1 parent 05dc092 commit 969d34b
Show file tree
Hide file tree
Showing 52 changed files with 826 additions and 917 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ protected override async Task OnInitAsync()
StateHasChanged();
});

unsubUserDataChange = PubSubService.Subscribe(PubSubMessages.USER_DATA_UPDATED, async payload =>
unsubUserDataChange = PubSubService.Subscribe(PubSubMessages.PROFILE_UPDATED, async payload =>
{
if (payload is null) return;
user = (UserDto)payload;
StateHasChanged();
});

user = (await PrerenderStateService.GetValue(() => HttpClient.GetFromJsonAsync("api/User/GetCurrentUser", JsonSerializerOptions.GetTypeInfo<UserDto>(), CurrentCancellationToken)))!;
user = (await PrerenderStateService.GetValue(() => HttpClient.GetFromJsonAsync("api/User/GetCurrentUser", AppJsonContext.Default.UserDto, CurrentCancellationToken)))!;

var serverAddress = Configuration.GetServerAddress();
var access_token = await PrerenderStateService.GetValue(() => AuthTokenProvider.GetAccessToken());
Expand All @@ -51,7 +51,7 @@ private async Task DoSignOut()
private async Task GoToProfile()
{
await CloseMenu();
navManager.NavigateTo(Urls.ProfilePage);
navManager.NavigateTo(Urls.SettingsPage);
}

private async Task HandleNavItemClick(BitNavItem item)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ private void CreateNavItems()
//#endif
new()
{
Text = Localizer[nameof(AppStrings.ProfileTitle)],
Text = Localizer[nameof(AppStrings.Settings)],
IconName = BitIconName.EditContact,
Url = Urls.ProfilePage,
Url = Urls.SettingsPage,
},
//#if (offlineDb == true)
new()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</ImageOverlayTemplate>
</BitPersona>
<BitSeparator />
<BitActionButton IconName="@BitIconName.Contact" Href="@Urls.ProfilePage" FullWidth OnClick="() => isOpen=false">
<BitActionButton IconName="@BitIconName.Contact" Href="@Urls.SettingsPage" FullWidth OnClick="() => isOpen=false">
@Localizer[nameof(AppStrings.ProfileTitle)]
</BitActionButton>
<BitActionButton IconName="@BitIconName.Globe" FullWidth OnClick="() => showCultures=true">
Expand All @@ -50,7 +50,7 @@
</BitActionButton>
<BitToggle OnChange="ToggleTheme" Value="currentTheme == AppThemeType.Light" ValueChanged="v => {}" />
</BitStack>
<BitActionButton IconName="@BitIconName.Globe" Href="@Urls.ProfilePage" FullWidth OnClick="() => isOpen=false">
<BitActionButton IconName="@BitIconName.Globe" Href="@Urls.SettingsPage" FullWidth OnClick="() => isOpen=false">
@Localizer[nameof(AppStrings.Settings)]
</BitActionButton>
<BitActionButton IconName="@BitIconName.SignOut" FullWidth OnClick="() => { showSignOut=true; isOpen=false; }">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public partial class UserMenu
private bool showSignOut;
private bool showCultures;
private UserDto user = new();
private string? currentCulture;
private string? profileImageUrl;
private Action unsubscribeUerDataUpdated = default!;
private BitChoiceGroupItem<string>[] cultures = default!;
Expand All @@ -32,7 +31,7 @@ protected override async Task OnInitAsync()
.ToArray();
}

unsubscribeUerDataUpdated = PubSubService.Subscribe(PubSubMessages.USER_DATA_UPDATED, async payload =>
unsubscribeUerDataUpdated = PubSubService.Subscribe(PubSubMessages.PROFILE_UPDATED, async payload =>
{
if (payload is null) return;

Expand All @@ -41,18 +40,17 @@ protected override async Task OnInitAsync()
await InvokeAsync(StateHasChanged);
});

user = (await PrerenderStateService.GetValue(() => HttpClient.GetFromJsonAsync("api/User/GetCurrentUser", JsonSerializerOptions.GetTypeInfo<UserDto>(), CurrentCancellationToken)))!;
user = (await PrerenderStateService.GetValue(() => HttpClient.GetFromJsonAsync("api/User/GetCurrentUser", AppJsonContext.Default.UserDto, CurrentCancellationToken)))!;

var serverAddress = Configuration.GetServerAddress();
var access_token = await PrerenderStateService.GetValue(() => AuthTokenProvider.GetAccessToken());
var access_token = await PrerenderStateService.GetValue(AuthTokenProvider.GetAccessToken);
profileImageUrl = $"{serverAddress}/api/Attachment/GetProfileImage?access_token={access_token}";

await base.OnInitAsync();
}

private async Task OnCultureChanged(string? cultureName)
{
currentCulture = cultureName;
await cultureService.ChangeCulture(cultureName);
}

Expand All @@ -63,7 +61,7 @@ private async Task ToggleTheme()

private async Task GoToProfile()
{
NavigationManager.NavigateTo(Urls.ProfilePage);
NavigationManager.NavigateTo(Urls.SettingsPage);
}

protected override async ValueTask DisposeAsync(bool disposing)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 969d34b

Please sign in to comment.